mirror of
https://github.com/logos-storage/logos-storage-nim-validator.git
synced 2026-01-03 14:03:07 +00:00
17 lines
310 B
Nim
17 lines
310 B
Nim
import pkg/nimcrypto/sha2
|
|
import pkg/nimcrypto/hash
|
|
|
|
export hash.`$`
|
|
|
|
type Hash* = MDigest[256]
|
|
|
|
func hash*(_: type Hash, bytes: openArray[byte]): Hash =
|
|
var context: sha256
|
|
context.init()
|
|
context.update(bytes)
|
|
result = context.finish()
|
|
context.clear()
|
|
|
|
func toBytes*(hash: Hash): auto =
|
|
hash.data
|