NodeCrypto Help

HMAC Generator

Category: Hash & MAC & CRC ยท Node Type ID: mac-hmac

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

Parameter Configuration

Parameter (ID)Type & DefaultVisibility ConditionDescription & Options
Hash Algorithm
algorithm
select
Default: 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).
  • SHA-256: SHA-256
  • SHA-512: SHA-512
  • SHA3-256: SHA3-256

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 NamePort IDData TypeRequiredVisibility ConditionDescription
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 NamePort IDData TypeVisibility ConditionDescription
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.

  1. Connect your secret key to Secret Key and payload bytes to Message with Hash Algorithm set to HMAC-SHA256 (32 Bytes).
  2. Connect the MAC Tag output to Operand A of a Compare node to verify against an expected MAC.