HMAC Generator
Sign a message with a secret key, and verify a signature you have been sent.
About the HMAC Generator
HMAC answers a question a plain hash cannot: not just "has this message changed", but "was it written by someone holding the key". That is why every webhook provider worth using signs its payloads with one, and why the signature they send has to be checked rather than trusted.
It is not the same as hashing the key and the message together. `sha256(key + message)` is vulnerable to a length-extension attack — an attacker who never sees the key can still append to the message and produce a valid-looking digest. HMAC's nested construction exists specifically to prevent that. This tool calls the browser's own Web Crypto implementation rather than reimplementing it, and the results are checked against the published RFC 4231 test vectors.
Getting a webhook check wrong usually comes down to what you signed. The signature covers the exact raw request body, byte for byte, before any JSON parsing. Parse it and re-serialise it and the bytes change, so the signature stops matching even though nothing was tampered with.
When comparing, use a constant-time comparison rather than `===`. An ordinary comparison stops at the first differing character, and the time it takes leaks how much of a guess was right — enough, over many attempts, to recover a valid signature. The verify box here uses one.
Everything happens in your browser. Your secret key is never sent anywhere, which is not a claim you should accept casually from any site asking for one.
How it works
Paste the message and the secret key.
Pick the hash — SHA-256 unless you have been told otherwise — and the output encoding.
Compare against a signature you were sent, if you are checking a webhook.
Frequently asked questions
- What is HMAC used for?
- Proving a message came from someone holding a shared secret and has not been altered. Webhook providers sign their payloads with it so you can tell a genuine delivery from anyone who happened to find your endpoint.
- How is HMAC different from a plain hash?
- A hash tells you the content has not changed; anyone can compute one. An HMAC needs the secret key, so it also tells you who produced it. It is also not simply `hash(key + message)` — that construction is open to length-extension attacks, which HMAC's nested design prevents.
- Why does my webhook signature not match?
- Almost always because you signed the wrong bytes. The signature covers the raw request body exactly as it arrived — parse the JSON and re-serialise it and the bytes change. Check the encoding too: providers vary between hex and Base64.
- Why should I not compare signatures with ===?
- Because it returns as soon as two characters differ, so how long it takes reveals how many leading characters were correct. Repeated enough times that leaks a valid signature. Use a constant-time comparison, as the verify box here does.
- Which hash should I use?
- SHA-256 unless the service you are integrating with specifies otherwise. SHA-1 is here because plenty of older APIs still require it — HMAC-SHA1 is not broken in the way plain SHA-1 is, but do not choose it for something new.
- Is my secret key sent anywhere?
- No. The signing uses your browser's own Web Crypto implementation and nothing leaves your device — which is the only acceptable answer for a page asking you to paste a production secret.
Privacy
Everything happens locally. Your files are read by your own browser, processed on your device, and never uploaded — closing the tab is all it takes to erase them.
Related tools
JWT Decoder
Decode a JSON Web Token's header and payload, and verify an HMAC signature.
SHA-256 Hash Generator
Generate a SHA-256 hash for text or files, with HMAC signing and checksum verification.
SHA-512 Hash Generator
Generate a SHA-512 hash for text or files, with HMAC signing and checksum verification.
Code to Image
Turn a code snippet into a shareable image, with syntax highlighting and themes.
Cron Expression Builder
Write a cron schedule, read it back in plain English, and see exactly when it will next run.
CSS Gradient Generator
Build linear, radial and conic CSS gradients visually and copy the code.