HMAC Generator
Hash-based Message Authentication Code (RFC 2104)
Overview
Computes a Hash-based Message Authentication Code (HMAC, RFC 2104 / FIPS 198-1) over an input message using a secret key and a selected underlying cryptographic hash function (SHA-256, SHA-384, SHA-512, SHA3-256, or SHA-1).
HMAC provides both data integrity and authenticity verification for parties sharing a secret key. Keys of any non-zero byte length are accepted (keys longer than the hash block size are hashed first; shorter keys are zero-padded to the block size per RFC 2104).
When to Use
- Authenticating API payloads, webhook requests, JWT HS256/HS384/HS512 tokens, or encrypt-then-MAC ciphertexts.
- Building custom key-derivation or challenge-response protocols.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Hash Algorithmalgorithm |
selectDefault: SHA-256 |
Always visible | Selects the underlying hash function and resulting MAC tag length: SHA-256 (32B), SHA-384 (48B), SHA-512 (64B), SHA3-256 (32B), or SHA-1 (20B).
|
Port I/O Specification
See Ports & Connections for general wiring rules, data type colors, and dynamic port creation.
Input Ports
Port Nature: Fixed Input Ports (2 total).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Secret Key |
key |
Bytes |
Required | Always visible | Secret HMAC key (Uint8Array; must be at least 1 byte). |
Message |
data |
Bytes |
Required | Always visible | Message payload (Uint8Array) to authenticate. |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
MAC Digest |
mac |
Bytes |
Always visible | Computed HMAC authentication tag (Uint8Array). |
Error Cases
This node has no runtime failure cases (errorProfile: none) and always succeeds for any valid typed input.
Examples
Computing and Verifying an HMAC-SHA256 Tag
Generate a 32-byte HMAC tag and compare it against an expected tag.
- Connect your secret key to
Secret Keyand payload bytes toMessagewith Hash Algorithm set toHMAC-SHA256 (32 Bytes). - Connect the
MAC Tagoutput to Operand A of a Compare node to verify against an expected MAC.