Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mac (HMAC)

Keyed authenticity without encryption. Distinct from Hash and Kdf. One-shot only.

ConstantAlgorithm
Mac.hmacSha256HMAC-SHA-256
MethodEffect
Mac.hash( algo key bytes -- tag:ByteList )
Mac.verify( algo key bytes tag -- bool ) constant-time

Key may be ByteList, String, or Key (uses key material).

Mac.hmacSha256 "demo-hmac-secret" msgBytes Mac.hash^ >ts
Mac.hmacSha256 "demo-hmac-secret" msgBytes t:peek Mac.verify^   // true
Mac.hmacSha256 "demo-hmac-secret" "tampered" t:peek Mac.verify^ // false

Example: examples/crypto/1b-hmac-tag.fnl. Prefer Env / Moniker for real shared secrets.