Skip to content

HMAC generator

Free, no sign-up Runs in your browser

Compute the HMAC of a message with a key given as text, hex or Base64, using SHA-256, SHA-384, SHA-512 or SHA-1. Hex and Base64 output. Runs in your browser.

Read as UTF-8, exactly as typed. A single different space or line break gives a different HMAC.

The key is
HMAC (hex)
Enter a key to see the HMAC.
HMAC (Base64)
Enter a key to see the HMAC.

Computed in your browser with Web Crypto. The message and the key are not sent anywhere. When you check an HMAC in your own code, compare with a constant-time function such as crypto.timingSafeEqual, not with ==.

Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.

How to use the HMAC generator

  1. Paste the message exactly as it was signed, such as the raw body of a webhook request.
  2. Enter the key and say whether it is text, hex or Base64.
  3. Choose the hash. HMAC-SHA-256 is the most common.
  4. Compare the hex or Base64 output with the signature you are checking.

About this tool

An HMAC is a keyed hash: a short value computed from a message and a secret key, which only someone holding the key can produce or check. It answers two questions at once, whether the message was changed and whether it came from someone who knows the secret. It is how webhooks from Stripe, GitHub, Slack and Shopify are signed, how HS256 JSON Web Tokens work, and how many APIs sign requests.

This tool computes it so you can debug a signature that will not verify. Enter the exact message and the key, choose the hash, and compare the output with the signature you received. The usual causes of a mismatch are all about bytes: the body was parsed and re-serialized instead of used raw, the key is hex or Base64 and was used as text, or the provider signs a timestamp plus the body and not the body alone.

HMAC is defined in RFC 2104 and is not the same as hashing the key and message together. A plain SHA-256 of key plus message is open to length extension, where an attacker appends data and computes a valid hash without the key; HMAC’s two nested hashes prevent that. When you verify in code, compare with a constant-time function, because an ordinary comparison leaks through timing how much of a forged signature was right.

Sources

Questions

What is the difference between a hash and an HMAC?

A hash needs no secret, so anyone can compute it: it detects accidental change but not forgery, since a forger simply recomputes it. An HMAC mixes in a secret key, so only the parties that share the key can produce a valid value. Use a hash for checksums and an HMAC for authentication.

Why does my webhook signature not match?

Most often the code hashes a parsed and re-encoded body instead of the raw bytes received. Other causes: using the signing secret in the wrong encoding, leaving out the timestamp or prefix the provider includes in the signed text, or comparing hex with Base64. Check the provider’s documentation for the exact signed string.

How long should an HMAC key be?

As long as the hash output is a sound rule: 32 random bytes for HMAC-SHA-256, 64 for HMAC-SHA-512. RFC 2104 discourages keys shorter than the output, and keys longer than the hash’s block size are hashed down first, which gains nothing. The key should be random, not a word.

Is HMAC-SHA-1 still secure?

Yes, as far as is known. The collision attacks that broke SHA-1 for signatures do not apply to HMAC, whose security rests on different properties. It remains in use in TOTP and older APIs. New systems should still choose HMAC-SHA-256.

Related tools