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 `==`(a: MultiHash; b: MultiHash): bool {....raises: [], tags: [], forbids: [].}
- Compares MultiHashes a and b, returns true if hashes are equal, false otherwise. 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 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