HMAC generator
An HMAC is a hash bound to a secret key. Given the same message and the same key, it produces the same signature; change either one and the signature changes completely. This page computes it locally.
RFC 2104 construction
Why a key changes everything
A plain hash answers "are these bytes the same?". An HMAC answers "were these bytes produced by someone who knows the secret?". The construction is deliberately simple: the key is padded to the algorithm's block size and XORed with two constants, then the message is hashed with the inner pad, and that result is hashed again with the outer pad.
HMAC(K, m) = H((K' ^ opad) || H((K' ^ ipad) || m))
For the message The quick brown fox jumps over the lazy dog and the key
key, that gives:
| Algorithm | Output |
|---|---|
| HMAC-MD5 | 80070713463e7749b90c2dc24911e275 |
| HMAC-SHA-1 | de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 |
| HMAC-SHA-256 | f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8 |
Use these as a sanity check: if your implementation reproduces them, your key padding and encoding are correct. If it does not, the usual cause is a key that was treated as Base64 or hex in one place and as raw text in the other.
HMAC-MD5 in 2026
HMAC-MD5 is not broken in the way bare MD5 is. Collision attacks on MD5 do not translate into forgery attacks on HMAC-MD5, and no practical attack on HMAC-MD5 exists. That is why it still appears in older payment gateways and signature schemes that were specified a decade ago and never updated.
It is still the wrong choice for new work, not because it is broken but because there is no reason to accept 128 bits of keyed output when SHA-256 costs nothing extra. If you are interoperating with an API that documents HMAC-MD5, use it exactly as specified. If you are designing the API, use HMAC-SHA-256.
Getting the message right
Almost every HMAC bug is a canonicalisation bug, not a crypto bug. Two parties compute the same HMAC only if they hash the same bytes, and "the same" is harder than it sounds:
- Key order in the canonical string. Most schemes specify sorted parameter names, lowercase keys, and no URL encoding.
- Line endings. A body signed with
\r\non Windows will not verify against one signed with\n. - Trailing newline. Many editors add one silently. The byte counter is the only reliable check.
- Encoding. Non-ASCII text must be UTF-8 on both sides, not the platform default.
- Empty parameters. Whether to include a parameter with an empty value is usually specified, and usually overlooked.
Compare in constant time. When you verify an HMAC in code, use a timing-safe comparison such as crypto.timingSafeEqual in Node or hmac.compare_digest in Python. A plain string comparison leaks information through how early it exits.
HMAC or a signature?
HMAC requires both sides to hold the same secret, which means the verifier can also forge a message. That is fine inside one trust domain — your server and your webhook sender — and wrong when you need to prove authorship to a third party. For that, use a public-key signature (Ed25519, ECDSA, RSA-PSS) where the verifier only holds the public key.
Related
- SHA-256 generator — the unkeyed version, for checksums.
- Hash identifier — identify an unknown digest.
- Password hashing — why HMAC is still not the right tool for passwords.
- Checksum verification — signatures versus checksums.