2024-12-10 15:47:37 +01:00

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