@eryx/crypto/hazmat/hmac Module

HMAC (Hash-based Message Authentication Code).

Computes an authentication tag over streamed 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/hazmat/hmac")
local hex  = require("@eryx/encoding/hex")

local key = buffer.fromstring("secret")
local ctx = hmac.new("sha256", key)
ctx:update(buffer.fromstring("hello"))
print(hex.encode(ctx:final()))

Summary

Classes

Context:update(data: buffer)()
Context:final()buffer
Context:close()()

Functions

hmac.new(algorithm: string, key: buffer)Context

API Reference

Classes

Context

Properties

Context:update

Context:update(data: buffer)()

Context:final

Context:final()buffer

Context:close

Context:close()()

Functions

hmac.new

Creates a streaming HMAC context.

Supported algorithms currently include "md5", "sha1", "sha224", "sha256", "sha384", "sha512", "sha3_224", "sha3_256", "sha3_384", and "sha3_512".

hmac.new(algorithm: string, key: buffer)Context

Parameters

algorithm: string

Hash algorithm name.

key: buffer

Secret key (any length).

Returns

Streaming HMAC context.