@eryx/crypto/hash Module

High-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:

local hash = require("@eryx/crypto/hash")

local digest = hash.digest(buffer.fromstring("hello"))
assert(hash.verify(buffer.fromstring("hello"), digest))

Summary

Functions

hash.digest(data: buffer)buffer
hash.verify(data: buffer, digest: buffer)boolean

API Reference

Functions

hash.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.

hash.digest(data: buffer)buffer

Parameters

data: buffer

Input data.

Returns

buffer

Tagged digest.

hash.verify

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.

hash.verify(data: buffer, digest: buffer)boolean

Parameters

data: buffer

Input data to check.

digest: buffer

Tagged digest previously returned by digest.

Returns

true if the digest matches.