mirror of
https://github.com/logos-storage/logos-storage-nim-validator.git
synced 2026-01-02 21:43:06 +00:00
15 lines
293 B
Nim
15 lines
293 B
Nim
import pkg/nimcrypto/sha2
|
|
import pkg/nimcrypto/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
|