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?): stringParameters
| Parameter | Type | Description |
|---|---|---|
key | string | Raw key bytes, not an implicitly decoded Base64 key. |
data | string | Raw message bytes. |
algorithm | string? | 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.
