This module implements MultiHash. Supported hashes are:
- IDENTITY
- SHA2-256/SHA2-512
- DBL-SHA2-256
- SHA3/KECCAK
- SHAKE-128/SHAKE-256
- BLAKE2s/BLAKE2s
- SHA1
Hashes which are not yet supported
- SKEIN
- MURMUR
Types
MHash = object mcodec*: MultiCodec size*: int coder*: MHashCoderProc
- Source Edit
MHashCoderProc = proc (data: openArray[byte]; output: var openArray[byte]) {. nimcall, ...gcsafe, noSideEffect, ...raises: [].}
- Source Edit
MultiHash = object data*: VBuffer mcodec*: MultiCodec size*: int dpos*: int
- Source Edit
Consts
MaxHashSize = 128
- Source Edit
Procs
proc `$`(mh: MultiHash): string {....raises: [], tags: [].}
- Return string representation of MultiHash value. Source Edit
proc `==`(a: MultiHash; b: MultiHash): bool {....raises: [], tags: [].}
- Compares MultiHashes a and b, returns true if hashes are equal, false otherwise. Source Edit
proc `==`[T](mdigest: MDigest[T]; mh: MultiHash): bool {.inline, ...raises: [].}
- Compares MultiHash with nimcrypto's MDigest[T], returns true if hashes are equal, false otherwise. Source Edit
proc `==`[T](mh: MultiHash; mdigest: MDigest[T]): bool {....raises: [].}
- Compares MultiHash with nimcrypto's MDigest[T], returns true if hashes are equal, false otherwise. Source Edit
proc base58(value: MultiHash): string {....raises: [], tags: [].}
- Return Base58 encoded string representation of MultiHash value. Source Edit
proc decode(mhtype: typedesc[MultiHash]; data: openArray[byte]; mhash: var MultiHash): MhResult[int] {....raises: [].}
-
Decode MultiHash value from array of bytes data.
On success decoded MultiHash will be stored into mhash and number of bytes consumed will be returned.
On error -1 will be returned.
Source Edit proc digest(mhtype: typedesc[MultiHash]; hashcode: int; data: openArray[byte]): MhResult[ MultiHash] {.inline, ...raises: [].}
- Perform digest calculation using hash algorithm with code hashcode on data array data. Source Edit
proc digest(mhtype: typedesc[MultiHash]; hashname: string; data: openArray[byte]): MhResult[ MultiHash] {.inline, ...raises: [].}
- Perform digest calculation using hash algorithm with name hashname on data array data. Source Edit
proc encode(mbtype: typedesc[MultiBase]; encoding: string; mh: MultiHash): string {. inline, ...raises: [].}
- Get MultiBase encoded representation of mh using encoding encoding. Source Edit
proc hex(value: MultiHash): string {....raises: [], tags: [].}
- Return hexadecimal string representation of MultiHash value. Source Edit
proc init(mhtype: typedesc[MultiHash]; data: openArray[byte]): MhResult[ MultiHash] {.inline, ...raises: [].}
- Create MultiHash from bytes array data. Source Edit
proc init(mhtype: typedesc[MultiHash]; data: string): MhResult[MultiHash] {. inline, ...raises: [].}
- Create MultiHash from hexadecimal string representation data. Source Edit
proc init(mhtype: typedesc[MultiHash]; hashcode: MultiCodec; bdigest: openArray[byte]): MhResult[MultiHash] {.inline, ...raises: [].}
- Create MultiHash from array of bytes bdigest and hash algorithm code hashcode. Source Edit
proc init(mhtype: typedesc[MultiHash]; hashname: string; bdigest: openArray[byte]): MhResult[MultiHash] {.inline, ...raises: [].}
- Create MultiHash from array of bytes bdigest and hash algorithm code hashcode. Source Edit
proc init58(mhtype: typedesc[MultiHash]; data: string): MultiHash {.inline, ...raises: [].}
- Create MultiHash from BASE58 encoded string representation data. Source Edit
proc init[T](mhtype: typedesc[MultiHash]; hashcode: MultiCodec; mdigest: MDigest[T]): MhResult[MultiHash] {.inline, ...raises: [].}
- Create MultiHash from nimcrypto's MDigest and hash algorithm code hashcode. Source Edit
proc init[T](mhtype: typedesc[MultiHash]; hashname: string; mdigest: MDigest[T]): MhResult[ MultiHash] {.inline, ...raises: [].}
- Create MultiHash from nimcrypto's MDigest object and hash algorithm name hashname. Source Edit