How to generate an HMAC
- Paste the message exactly as it was signed — for webhooks, that is the raw request body, byte for byte. Re-formatting JSON (adding or removing spaces) changes the signature.
- Enter the secret key. Most services give you a text secret; choose Hex or Base64 if your key is in one of those encodings.
- Pick the output format your service uses. The HMAC is calculated with all five algorithms at once.
- Paste a received signature into Compare to see whether it matches and which algorithm produced it.
What HMAC is and where it’s used
HMAC (hash-based message authentication code, RFC 2104) combines a cryptographic hash with a secret key. Only someone who knows the key can produce the right code for a message, so the receiver can check that the message came from the sender and wasn't changed on the way. Unlike a plain hash, an attacker can't recompute it after tampering with the message.
| Service | Typical scheme |
|---|---|
| Stripe webhooks | HMAC-SHA256 of timestamp.body, hex, in the Stripe-Signature header |
| GitHub webhooks | HMAC-SHA256 of the body, hex, X-Hub-Signature-256: sha256=… |
| Shopify webhooks | HMAC-SHA256 of the body, Base64, X-Shopify-Hmac-Sha256 |
| AWS Signature v4, JWT HS256 | HMAC-SHA256 (with their own message format) |
Exact formats are defined in each provider's documentation and can change; check it when a signature doesn't match.
When signatures don’t match
- The body was modified. Frameworks often parse and re-serialize JSON before your code sees it. Sign the raw bytes as received.
- Wrong secret. Test and live mode, or different endpoints, usually have different secrets.
- Extra data in the signed string. Some providers sign a timestamp or URL together with the body.
- Encoding mismatch. Compare hex with hex and Base64 with Base64; the Compare box accepts either.
- Line endings or a trailing newline added when copying the body.
In production code, compare signatures with a constant-time function (such as crypto.timingSafeEqual in Node.js or hmac.compare_digest in Python), not with ==.
Frequently asked questions
Is my secret key sent anywhere?
No. The HMAC is computed with your browser’s Web Crypto API (and our own MD5 implementation for HMAC-MD5) on your device. The page has no code that transmits it.
Which algorithm should I use?
HMAC-SHA256 is the standard choice and what most APIs expect. HMAC-SHA512 is equally fine. HMAC-SHA1 and HMAC-MD5 are still considered secure as MACs but are only worth using for compatibility with older systems.
What is the difference between a hash and an HMAC?
Anyone can compute a hash of a message. An HMAC also requires a secret key, so it proves the message was produced by someone who knows the key and hasn’t been altered.
Can I use an empty key?
Yes; HMAC is defined for empty keys, and the tool computes it, but it provides no security. It can be useful to reproduce test vectors.