HMAC Generator
Calculate HMAC-SHA256, SHA-512, SHA-384 or SHA-1 signatures and verify webhook signatures with your secret.
Runs in your browser. Nothing is uploaded.
How to use the HMAC Generator
- Paste the message into the top box, exactly as it was sent, or press Load example.
- Enter the secret key and choose whether it's plain text, hex or Base64.
- Choose the hash function. SHA-256 is the most common.
- The HMAC appears in hex and Base64 as you type.
- Paste a received signature in the compare box to check it matches. A sha256= prefix is ignored.
Sign and verify messages with a shared secret
HMAC signatures protect webhooks, API requests and one-time links. A payment provider signs each webhook it sends with a secret only you and it know. Your server recalculates the HMAC and accepts the request only if the signatures match. When that check fails and you can’t see why, you need to calculate the HMAC yourself. This tool does exactly that.
Flexible inputs
- Key formats: plain text, hex or Base64, because providers store secrets in different forms
- Hash functions: SHA-256, SHA-512, SHA-384 and SHA-1
- Output: lowercase hex, the most common form, and Base64, used by several providers
- Comparison: paste the signature from the request header. Common prefixes like
sha256=are stripped, and either hex or Base64 is recognised.
Getting a match
Most mismatches come from the message, not the maths. Webhook signatures are computed over the raw request body. If your framework parses the JSON and you re-serialise it, spaces and key order change, and the HMAC no longer matches. Some providers sign a combination, such as a timestamp, a dot and the body. Read the provider’s documentation to see exactly what’s signed, build the same string here, and compare.
Secure comparisons
When you implement verification in code, compare signatures with a constant-time function, such as
crypto.timingSafeEqual in Node.js or hmac.compare_digest in Python, so attackers can’t learn the
signature from response timing. All calculations here run on your device. For plain hashes without a key,
use the SHA-256 Generator.
Frequently asked questions
What is an HMAC?
An HMAC (hash-based message authentication code) combines a secret key with a message and a hash function to produce a signature. Only someone with the same key can produce the same HMAC, so it proves the message came from them and wasn't changed on the way.
How is HMAC different from a plain hash?
Anyone can calculate the SHA-256 of a message, so a plain hash only detects accidental changes. An HMAC also needs the secret key, so an attacker who changes the message can't produce a valid signature.
Why doesn't my HMAC match the webhook's signature?
The message must be byte-for-byte identical to what was signed, usually the raw request body before any JSON parsing or reformatting. Also check the key format (some providers Base64-encode secrets), the hash function, and whether the signature is hex or Base64.
Which hash should I use?
Use whatever the other side expects, most often SHA-256. HMAC-SHA1 is still secure in practice but considered legacy, so prefer SHA-256 or SHA-512 for new systems.
Is my secret safe here?
The HMAC is calculated by your browser's Web Crypto API, and the key never leaves the page. Still, avoid pasting production secrets into any website when a test secret will do.
Tutorials
How to verify a webhook signature with HMAC-SHA256
Recalculate a webhook's HMAC from its raw body and secret to check it's genuine, and find out why a signature doesn't match.