Free Online HMAC Generator and Verifier
Runs in this tab. A token, a key, a config — whatever you paste stays local.
Loading the tool…
How it works
RFC 2104, and why it is not just hash(key + message)
HMAC is defined in RFC 2104 as H((K ⊕ opad) ‖ H((K ⊕ ipad) ‖ message)) — two nested hashes with the key mixed in twice using different pads. That construction exists because the obvious approach, hashing the key concatenated with the message, is vulnerable to length-extension against Merkle-Damgård hashes like SHA-2. The output is the same length as the underlying hash: 32 bytes for HMAC-SHA256, 64 for HMAC-SHA512.
- Key
- Any length. Keys longer than the block size are hashed first; shorter ones are zero-padded, both by the spec.
- Algorithm
- HMAC-SHA256, SHA-384 or SHA-512, via WebCrypto. The digest length follows the hash.
- Message bytes
- Signed as UTF-8. Webhook verification must use the exact raw request body — re-serialised JSON produces a different signature.
- Output
- Hex or Base64. Providers differ: Stripe sends hex, several others send Base64, and comparing across encodings always fails.
- Comparison
- Verify with a constant-time compare such as crypto.timingSafeEqual. A plain === leaks how much of the signature matched.
How to use it
How to generate an HMAC signature online
- 01
Enter the secret key
The signing secret from the provider's dashboard, or your own.
- 02
Paste the message
For a webhook, the raw body exactly as received — bytes, not reformatted JSON.
- 03
Compare the digest
Match it against the provider's header, in the same encoding.
Where it earns its keep
Where HMAC is the mechanism
- Reproducing a Stripe or GitHub webhook signature to debug a rejected delivery.
- Signing an internal API request between two services that share a secret.
- Producing a tamper-evident token for a short-lived download URL.
- Checking an implementation against a known test vector.
Questions
HMAC Generator, answered
Is it safe to paste my signing secret here?
The key is used by WebCrypto inside this browser tab and appears in no network request, so it does not reach us or anyone else. It is still a production secret: use a test key where you can, and rotate anything you have pasted into a tool you have not verified.
Why does my webhook signature never match?
Almost always the message bytes. Frameworks parse and re-serialise the JSON body before you see it, which changes whitespace and key order and therefore the HMAC. You must sign the raw body, and include the timestamp prefix if the provider specifies one.
Is HMAC the same as a digital signature?
No. HMAC uses one shared secret, so anyone who can verify can also forge. A digital signature uses a private key to sign and a public key to verify, which is what gives non-repudiation. HMAC does not.
Why does constant-time comparison matter?
A normal string comparison returns as soon as it finds a difference, so the time it takes reveals how many leading characters were right. Over enough attempts that recovers a valid signature byte by byte. Verify with a constant-time function.