%3C/text%3E%3C/svg%3E">
💻
💻 Tech & IT

HMAC-SHA256 Generator

Results update as you type.

Your numbers

Understanding the HMAC-SHA256 generator — concept and principle

HMAC-SHA256 is a keyed message authentication code: it combines a secret key with a message to produce a 256-bit tag that only someone holding the key can create or verify. This tool computes the tag in your browser. HMAC is used to sign API requests and webhooks, to create HS256 JSON Web Tokens, and to check that cookies or messages were not altered.

HMAC nested hashingThe key secret is padded to 64 bytes, XORed with 0x36 and hashed with the message, then XORed with 0x5c and hashed with that inner result, giving 7a284e50…cd2cd0eb1.Key + message, hashed twice"secret"6 bytes + 58 zero bytes = 64① innerkey ⊕ 0x36+message32 B"The quick brown fox"② outerkey ⊕ 0x5c+inner 32 Btag7a284e5025f32a846fa3e6957d10278eb5726dd4e0b04c8e0259defcd2cd0eb1Without the key nobody can make this tag
The outer hash wraps the inner one, which blocks length-extension tricks.

How it is calculated

HMAC(K, m) = H((K′ ⊕ opad) ∥ H((K′ ⊕ ipad) ∥ m)), defined in RFC 2104.

The principle

A plain hash of key ∥ message is unsafe with SHA-256, because its Merkle–Damgård structure lets an attacker extend a message and compute a valid hash without the key (a length-extension attack). HMAC wraps the message in two nested hashes with two different derived keys; the outer hash hides the inner state, which blocks that attack. Its security is proven to rest on the pseudorandomness of the hash's compression function, so HMAC remains secure even with hashes whose collision resistance is weakened.

Worked example

  1. Key "secret" (6 bytes) is padded with 58 zero bytes to 64 bytes.
  2. Inner: XOR the padded key with 0x36, append the UTF-8 bytes of "The quick brown fox", and hash with SHA-256.
  3. Outer: XOR the padded key with 0x5c, append the 32-byte inner digest, and hash again.
  4. Result: 7a284e5025f32a846fa3e6957d10278eb5726dd4e0b04c8e0259defcd2cd0eb1.

How to read the result

The receiver recomputes the tag with the shared key and accepts the message only if the tags match exactly. Any change to the key or message, even one character or case, produces a completely different tag. Some APIs expect the tag in Base64 instead of hex; the bytes are the same.

Common mistakes

Keep in mind: HMAC proves integrity and authenticity, not secrecy: the message itself is not encrypted. Never paste a production secret key into a tool on a shared or untrusted device.

Frequently asked questions

Is HMAC the same as encryption?

No. It produces a tag that proves the message is unchanged; anyone can still read the message.

What key length should I use?

RFC 2104 recommends a key at least as long as the hash output, so 32 bytes for SHA-256.

Why does my result differ from another tool?

Check the encoding of the key (text, hex or Base64), trailing newlines, and whether the output is hex or Base64.

Sources: RFC 2104, HMAC: Keyed-Hashing for Message Authentication · NIST FIPS 198-1, The Keyed-Hash Message Authentication Code (HMAC) · RFC 4231, Identifiers and Test Vectors for HMAC-SHA-224, -256, -384 and -512

Checked 8 Nov 2026. Standard formulas and RFC/IEEE definitions, computed locally in your browser — nothing you type is sent anywhere.

💻 All tech & IT tools →🌍 Calculators by country →