An HMAC generator combines a message with a secret key to produce a keyed hash, or message authentication code. Anyone who knows the key can recompute it to confirm the message is genuine and unchanged. Enter the message and key, choose SHA-256, SHA-384, SHA-512 or SHA-1, and copy the result.
How to use the HMAC Generator
- Enter the messagePaste the exact text that is signed, byte for byte. For webhooks this is normally the raw request body.
- Enter the secret keyType the key and say whether it is plain text, hex or Base64. Then choose the hash function your API uses.
- Copy the HMACCopy the hex, Base64 or Base64URL form, whichever the other system expects, and compare.
How HMAC works
A plain hash such as SHA-256 proves nothing about who created a message, because anyone can hash anything. HMAC (RFC 2104) fixes that by mixing a secret key into the calculation. In outline, the key is padded to the block size of the hash and used twice: HMAC = H((key XOR opad) + H((key XOR ipad) + message)). Without the key, the result cannot be forged or checked.
This HMAC generator uses the Web Crypto API in your browser. The length of the output depends on the hash: HMAC-SHA256 gives 32 bytes (64 hex characters), HMAC-SHA384 gives 48 bytes, HMAC-SHA512 gives 64 bytes and HMAC-SHA1 gives 20 bytes. HMAC-SHA1 is still considered sound as a MAC, but new systems should use SHA-256 or stronger.
You can test the tool with the example from RFC 4231: the key Jefe and the message what do ya want for nothing? give an HMAC-SHA256 that starts with 5bdcc146bf60754e.
Where HMAC is used, and getting matching results
- Webhook signatures. Services such as payment providers and code hosts sign each webhook body with a shared secret and send the HMAC in a header. Your server recomputes it and rejects requests that do not match.
- API request signing, where a timestamp and the request details are signed so that requests cannot be forged or replayed.
- JSON Web Tokens. The HS256 algorithm is HMAC-SHA256 over the encoded header and payload; inspect tokens with the JWT decoder.
When your result differs from the expected one, the cause is almost always the input bytes, not the algorithm:
- The message must be identical, including spaces, line endings and a final line break.
- The key format matters. A key given as hex or Base64 must be decoded to bytes first, so choose the matching option.
- Check which output encoding the other side uses: hex, Base64 or Base64URL.
On a server, compare signatures with a constant-time function so that timing does not leak information. Need a strong secret? The random string generator can create one. Nothing you type here is sent anywhere.
Frequently asked questions
What is an HMAC?
HMAC stands for hash-based message authentication code. It is a hash calculated from a message and a secret key, used to check that a message is authentic and has not been altered.
How do I generate an HMAC-SHA256?
Paste the message into the HMAC generator, enter the secret key, leave the hash function on HMAC-SHA256 and copy the hex or Base64 result.
What is the difference between a hash and an HMAC?
A hash depends only on the data, so anyone can compute it. An HMAC also depends on a secret key, so only someone with the key can create or verify it.
Why does my HMAC not match the one from the API?
Check that the message is byte-for-byte the same, including whitespace and line breaks, that the key is decoded correctly from text, hex or Base64, and that you are comparing the same output format.
Is it safe to type my secret key here?
The calculation happens in your browser and the key is not transmitted or stored. As a general habit, though, use test keys in online tools and keep production secrets in your own environment.
Last updated 24 November 2026 by the TheTechFolk team.