AcediaDocumentation

crypt.hmac

Computes an HMAC and returns its digest in Base64.

The key is the first argument. To use raw bytes generated by crypt.generatekey, decode them first.

crypt.hmac(key: string, data: string, algorithm: string?): string

Parameters

ParameterTypeDescription
keystringRaw key bytes, not an implicitly decoded Base64 key.
datastringRaw message bytes.
algorithmstring?Defaults to sha256; uses the hash algorithm names supported by crypt.hash.

Example

local tag = crypt.hmac("example-key", "message", "sha256")
print(tag)

Example output

HykREg1EiVrC7zKlVG1FkbymPIh0sluy0whbYvbAhLg=

Deterministic for this key/message/algorithm triple; the tag is returned as Base64.

Errors: Unknown algorithm names raise an error.

On this page