2024-12-18 10:19:09 +01:00

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