HMAC Generator
Developer Tools · Added
A plain hash proves a message has not changed. An HMAC proves it came from somebody holding the key — which is why webhook providers sign with one. Paste the message and the key, pick the hash, and compare the result against what arrived.
How to use the hmac generator
- 1Paste the exact message that was signed, byte for byte, into the message box.
- 2Enter the secret key and say how it is written: plain text, hex or Base64.
- 3Pick the hash algorithm the sender used — SHA-256 unless their docs say otherwise.
- 4Read the digest as hex, Base64 or Base64url, or paste the expected value in to compare.
Examples
A short message with a text key
- Input
- Message "The quick brown fox", key "secret", SHA-256
- Result
- 7a284e5025f32a846fa3e6957d10278eb5726dd4e0b04c8e0259defcd2cd0eb1
Flagged with a warning: a 6-byte key is well short of the 32 bytes RFC 2104 recommends for SHA-256.
Checking a webhook signature
- Input
- The raw request body, the shared secret as Base64, SHA-256, output as Base64
- Result
- A digest to set against the provider's signature header. A mismatch usually means the body was re-serialised before it reached you.
About the hmac generator
Why HMAC is not just hash(key + message)
The obvious construction — concatenate the key and the message, then hash — is broken against the hash functions people actually use. SHA-1 and the SHA-2 family are built on the Merkle-Damgård construction, which lets somebody who knows a digest and the message length append data and compute a valid digest for the longer message, with no knowledge of the key at all. It is called a length-extension attack and it is entirely practical.
HMAC exists specifically to close that hole. It hashes twice with two different key-derived pads, so the final digest is a hash of a hash and the internal state an attacker would need to extend is never exposed. That structure is why the standard is a standard rather than a note saying 'stick the key on the front'.
Key length, and what the standard actually asks for
RFC 2104 recommends a key at least as long as the hash output — 32 bytes for SHA-256 — because the security of the construction is capped by the key's own length. A four-character password used as an HMAC key is guessable regardless of how strong the underlying hash is, and this page says so when you use one.
The other end has a limit too. A key longer than the hash's block size, 64 bytes for SHA-256, gets hashed down to the output length before use, so extra bytes beyond that add nothing at all. Somewhere between the output length and the block size is the whole useful range.
Frequently asked questions
How does an HMAC differ from a plain hash?
My signature does not match. What is usually wrong?
Where does the computation happen?
Should I still use SHA-1 here?
Why does comparing here not have the timing problem I have read about?
Related tools
Hash Generator
Developer Tools
Generate SHA-256, SHA-384, SHA-512 or SHA-1 digests of text or a file, and verify a checksum.
Base64 Encoder / Decoder
Developer Tools
Encode text to Base64 and decode it back, with full Unicode and URL-safe support.
JWT Decoder
Developer Tools
Decode a JSON Web Token's header, payload and claims, and see whether it has expired.