HMAC Generator

Calculate an HMAC (SHA-256, SHA-512, SHA-1, MD5) from a message and a secret key.

Result

HMAC-SHA-256 f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
  • An HMAC proves a message came from someone who knows the key and was not changed. Compare tags with a constant-time function in real code, and keep keys secret.

What is an HMAC?

An HMAC (hash-based message authentication code) is a hash that also depends on a secret key. Only someone who knows the key can produce the right value for a message. It proves two things: the message came from a holder of the key, and it was not changed on the way.

It is not simply the hash of the key and message joined together. HMAC mixes the key into the hash in two rounds, which avoids weaknesses of the simple approach. APIs and webhooks use it to sign requests, and JWTs with HS256 use it for their signature. Keep the key secret.

Formula

HMAC(K, m) = H((K′ ⊕ opad) ‖ H((K′ ⊕ ipad) ‖ m))

How to use the HMAC Generator

  1. Enter the message.
  2. Enter the secret key, and say whether it is text or hex.
  3. Choose the hash algorithm.
  4. Pick hex or Base64 and copy the HMAC.

Real situations

When people use the HMAC Generator

  • 1

    Check a webhook signature

    Many services send an HMAC of the request body. Recompute it with your shared secret to see whether it matches.

  • 2

    Sign an API request

    Reproduce the signature your client should send, so you can debug a "signature mismatch" error.

  • 3

    Test a JWT secret

    HS256 tokens use HMAC-SHA-256. Compute the tag by hand to see how it relates to your key.

  • 4

    Learn how keyed hashes behave

    Change one letter of the key or message and watch the whole output change.

Good to know

  • Use the exact bytes of the message. A different line ending or whitespace changes the tag.

FAQ

HMAC Generator: questions answered

What is the HMAC-SHA256 of the sample?

With the key "key" and the message "The quick brown fox jumps over the lazy dog", HMAC-SHA-256 is f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8. With SHA-1 it is de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9.

How is HMAC different from a plain hash?

A plain hash can be computed by anyone, so it only shows that data matches. An HMAC needs the secret key, so it also shows who made it. Without the key an attacker cannot create a valid tag for a changed message.

Is HMAC-MD5 or HMAC-SHA1 safe?

The known collision attacks on MD5 and SHA-1 do not directly break HMAC, but modern guidance is to choose SHA-256 or stronger for anything new. The weaker options are here for legacy systems.

What if my key is hex or Base64?

Set "Key is" to hex bytes if your key is written as hex. If it is Base64, decode it to bytes first, since this tool accepts either text or hex. Using the wrong form gives a different result.

Is HMAC encryption?

No. The message stays readable. HMAC only proves origin and integrity. If you need secrecy, you must encrypt the message too.

How should I compare HMACs in code?

Use a constant-time comparison function from your language or library. Ordinary string comparison can leak information through timing differences. Keep keys out of source control.

How does the HMAC Generator work?

HMAC(K, m) = H((K′ ⊕ opad) ‖ H((K′ ⊕ ipad) ‖ m)) Results update as you type.

Is this HMAC Generator free and private?

Yes. It is free with no sign-in, and every calculation runs inside your browser. Nothing you type is sent to a server or stored, and the page keeps working offline once it has loaded.

Private by design. No accounts, no cookies, no tracking. Everything you type stays on your device.

How we keep it that way