ReferenceEncoding and crypto

crypt.hmac

Computes a keyed digest and returns Base64 text.

Syntax

crypt.hmac(key: string, data: string, algorithm: string) -> string

Parameters

ParameterTypeDescription
keystringRaw authentication-key bytes.
datastringMessage bytes.
algorithmstringSupported digest name, for example sha256.

Returns

TypeDescription
stringBase64-encoded HMAC.

Description

The key is a raw byte string, unlike the Base64 key parameter of crypt.encrypt. Use the same key, input bytes and algorithm when checking another result. This authenticates data; it does not hide the message.

Example

local key = crypt.random(32)
print(crypt.hmac(key, "hello", "sha256"))

These are Game executor contracts. Check build requirements and session lifetimes before using them.