Computes HMAC-MD5 over data with key.
@eryx/crypto/hmac Module
JSON
HMAC (Hash-based Message Authentication Code).
Computes an authentication tag over data using a secret key and the
chosen hash algorithm. The output length equals the digest size of the
underlying hash.
local hmac = require("@eryx/crypto/hmac")
local hex = require("@eryx/encoding/hex")
local key = buffer.fromstring("secret")
local msg = buffer.fromstring("hello")
print(hex.encode(hmac.sha256(key, msg)))
Summary
Functions
API Reference
Functions
hmac.md5
Parameters
Secret key (any length).
Input data.
Returns
16-byte MAC.
hmac.sha1
Computes HMAC-SHA1 over data with key.
Parameters
Secret key (any length).
Input data.
Returns
20-byte MAC.
hmac.sha224
Computes HMAC-SHA224 over data with key.
Parameters
Secret key (any length).
Input data.
Returns
28-byte MAC.
hmac.sha256
Computes HMAC-SHA256 over data with key.
The most common HMAC variant. Suitable for API authentication, signed cookies, and TOTP/HOTP tokens.
Parameters
Secret key (any length).
Input data.
Returns
32-byte MAC.
hmac.sha384
Computes HMAC-SHA384 over data with key.
Parameters
Secret key (any length).
Input data.
Returns
48-byte MAC.
hmac.sha512
Computes HMAC-SHA512 over data with key.
Parameters
Secret key (any length).
Input data.
Returns
64-byte MAC.
hmac.sha3_224
Computes HMAC-SHA3-224 over data with key.
Parameters
Secret key (any length).
Input data.
Returns
28-byte MAC.
hmac.sha3_256
Computes HMAC-SHA3-256 over data with key.
Parameters
Secret key (any length).
Input data.
Returns
32-byte MAC.
hmac.sha3_384
Computes HMAC-SHA3-384 over data with key.
Parameters
Secret key (any length).
Input data.
Returns
48-byte MAC.
hmac.sha3_512
Computes HMAC-SHA3-512 over data with key.
Parameters
Secret key (any length).
Input data.
Returns
64-byte MAC.