Computes a tagged digest of data.
The current implementation uses a fixed hash choice internally and
returns a self-describing tagged buffer rather than exposing the
algorithm at the call site.
@eryx/crypto/hash ModuleHigh-level message digests.
This module provides a single digest API for application code that does not want to care which hash function is currently preferred.
The returned digest is a tagged buffer, allowing the underlying
algorithm to change in the future without making stored digests
ambiguous.
The current format is:
"$h$" || raw_digestlocal hash = require("@eryx/crypto/hash")
local digest = hash.digest(buffer.fromstring("hello"))
assert(hash.verify(buffer.fromstring("hello"), digest))
Computes a tagged digest of data.
The current implementation uses a fixed hash choice internally and
returns a self-describing tagged buffer rather than exposing the
algorithm at the call site.
Input data.
Tagged digest.
Verifies that digest matches data.
Returns true if the digest is well-formed, uses a supported tag, and
matches the supplied data. Returns false for malformed or mismatched
values.
Input data to check.
Tagged digest previously returned by digest.
true if the digest matches.