HMAC generator

Enter a message and a secret key and see the HMAC for SHA-1, SHA-256, SHA-384 and SHA-512 at once. The key can be plain text, hex or Base64. Everything is computed by your browser's Web Crypto, and neither the key nor the message is sent anywhere.

Key is written as
Output format

HMAC-SHA-1 is still considered safe as a MAC, but prefer SHA-256 or stronger for new designs. Never reuse a signing key as a password.

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Type or paste the message.
  2. Enter the secret key and tell the tool how it is written: text, hex or Base64.
  3. Pick hex or Base64 output and copy the HMAC you need.

How it works

HMAC (RFC 2104) hashes the message twice, mixing in the key each time: HMAC(K, m) = H((K ⊕ opad) ‖ H((K ⊕ ipad) ‖ m)). A key longer than the hash’s block size is hashed first, and a shorter one is padded with zero bytes. The tool calls the browser’s Web Crypto implementation, so the result matches your server’s.

Known test vector (RFC 4231, case 2): key Jefe, message what do ya want for nothing? gives HMAC-SHA-256 5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843. For HMAC-SHA-1 the same inputs give effcdf6ae5eb2fa2d27416d5f184df9c259a7c79 (RFC 2202).

Tips

  • The tag is the same length as the hash: 20, 32, 48 or 64 bytes.
  • Compare tags in constant time in your own code, not with ==.
  • Use a random key of at least the hash’s output length for signing.

Frequently asked questions

What is HMAC used for?

HMAC proves that a message was produced by someone who knows the shared secret key and that it was not changed on the way. Webhook signatures, API request signing and JWT HS256 tokens all use it.

Which hash should I pick?

Use whatever the other side expects. If you are free to choose, HMAC-SHA-256 is the usual default. SHA-512 gives a longer tag, and SHA-1 only suits older systems.

Why does my result differ from my server's?

Check the key encoding first. A key given as hex or Base64 must be decoded to bytes, while a text key is used as its UTF-8 bytes. Also check for trailing newlines or spaces in the message and use the same output format.

Is an empty key allowed?

Yes. Browsers refuse a zero-length key in Web Crypto, so the tool uses a single zero byte instead. This gives the same HMAC, because HMAC pads the key with zero bytes anyway.

Is my secret key uploaded?

No. The calculation happens in your browser with the Web Crypto API, and nothing is sent to a server. Still, avoid pasting production secrets on any shared computer.

More in Developer

All tools in this category: Developer ·Updated November 3, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.