You download a file, hash it, and the digest matches the one on the website. That tells you the file is the file. Now a payment provider sends your server a message saying an order was paid. You hash that message and it matches itself perfectly, which tells you nothing, because anyone could have written the message and hashed it too.
That gap is exactly what an HMAC fills. This guide explains what a plain hash proves, what changes when a secret key is mixed into the signature, and how to produce one with the free HMAC Generator on Ovatly, which signs on your device.
Contents
- Quick answer
- What a plain hash actually proves
- What the secret key changes
- Shared secret means shared power
- Which hash sits inside the HMAC
- How to compute an HMAC, step by step
- Worked example: the fox test value
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
A plain hash proves a message matches its digest, and since anyone can recompute a hash, it proves nothing about who produced the message. An HMAC runs the message through a hash together with a secret key, so the signature can only be produced or checked by a key holder. To make one, open the HMAC Generator, paste the exact message byte for byte, enter the secret key, pick SHA-256, SHA-384 or SHA-512, and copy the signature in hex or Base64, whichever the receiving system expects.
What a plain hash actually proves
A hash takes any input and produces a fixed-length digest. Change one character of the input and the digest changes completely. That makes hashes excellent fingerprints: if two digests match, the two inputs were identical.
But a fingerprint is all it is. The algorithm is public and the input is usually visible, so a hash attached to a message proves only that the message and the digest belong together. It cannot prove who attached it. An attacker who alters the message can simply hash the altered version and attach the fresh digest, and your check passes. Integrity against accidents, yes. Proof of origin, no.
What the secret key changes
An HMAC keeps the hash but mixes a secret key into the computation. Now the output depends on two things: the message and a key that only the legitimate parties hold. Someone who intercepts the message cannot produce a valid signature for an altered version, because they do not have the key. A checker recomputes it with their copy of the key; a match means the message is unchanged and was signed by a key holder.
That is the entire difference. The plain hash answers "is this the same message?" The HMAC answers that and a second question: "did it come from one of us?" The test value in the worked example below shows the effect: the same sentence, signed with the key "key", produces a result no unkeyed hash can reproduce.
Shared secret means shared power
The key in an HMAC is a shared secret, and that shapes where HMACs belong. Every party who can verify a signature can also create one, because verification and signing are the same operation with the same key. No third party can tell which key holder signed a given message.
So HMACs fit setups where two systems trust each other and share a secret in advance: an API and its client, a webhook sender and its receiver. They do not replace public-key signatures, where a private key signs and a public key lets anyone verify without gaining the power to sign. Choosing between them is choosing a trust model, not a strength level.
Which hash sits inside the HMAC
An HMAC is built on top of a hash, and the Ovatly generator offers three: SHA-256, SHA-384 and SHA-512. SHA-256 is the sound default for most systems, and a random key of 32 bytes or more is a sound default to pair with it. HMAC-SHA-1 and anything built on MD5 are deliberately not offered; the weaker hashes have already been shown to be breakable.
Pick the variant the receiving system specifies. Two sides computing with different hashes will never agree, and the failure looks like a wrong key. When you control both sides, choose SHA-256 and note the choice.
How to compute an HMAC, step by step
-
Open the HMAC Generator and paste the exact message, byte for byte. Whitespace and line endings are part of the message, and a trailing newline changes the signature completely.
-
Enter the secret key exactly as issued. A key written as hex digits is a different key from the same characters treated as plain text.
-
Pick the hash: SHA-256, SHA-384 or SHA-512, matching what the receiving system expects.
-
Click Compute HMAC and copy the signature in the format the system expects, hex or Base64. They are the same bytes in two encodings.
Everything runs on your device through the browser's Web Crypto support. Even so, do not sign production secrets on a machine you do not trust.
Worked example: the fox test value
The standard test case uses the message "The quick brown fox jumps over the lazy dog" with the key "key". Signed with HMAC-SHA-256, the result is:
f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
Run the same sentence through a plain SHA-256 hash and you get a completely different digest, one anyone can reproduce. The HMAC value above can only be reproduced by someone who knows the key is the word "key". Change the key by one character, or add a trailing newline to the message, and the signature changes completely, which is precisely what makes verification meaningful. Reproduce this value in the generator to confirm your setup before wiring it into anything real.
Limitations and honest tradeoffs
An HMAC does not encrypt. The message stays readable to anyone who sees it; the signature proves origin and integrity, not secrecy. You also cannot decrypt an HMAC or recover anything from it. Verification always means signing the message again with the key and comparing the two signatures.
The shared-secret model carries its own weight. The key has to be distributed to every verifier, stored safely by each, and replaced everywhere if it leaks. And because every verifier can sign, an HMAC can never settle a dispute about which key holder produced a message. Finally, the tool signs one message at a time by hand; it is a testing aid, not part of a live system.
Common mistakes
- Hashing when you needed authentication. A plain digest proves nothing about its sender. If origin matters, the signature has to involve a secret.
- Signing text that was re-serialised. If a system parses JSON and signs the re-printed version, the bytes differ from what was sent and verification fails elsewhere. Sign the raw bytes.
- Mixing up the key format. A hex key treated as text, or a text key decoded as hex, produces a valid-looking signature that never matches.
- Comparing across encodings. A hex signature checked against a Base64 one will never match, even when both describe the same bytes. Convert first.
- Reaching for the weakest option. If a legacy counterpart demands HMAC-SHA-1, treat that as a finding to report, not a setting to quietly accept.
FAQs
What does an HMAC prove that a plain hash does not? A plain hash proves the message matches the digest, and anyone can recompute it to check. An HMAC proves the same match and that the signature was produced by someone holding the shared secret key, because nobody without the key can produce a valid one.
Can anyone verify an HMAC? Only someone who holds the secret key. Anyone with the key can both sign and verify, which is why HMAC suits shared-secret setups between two parties who trust each other. It is not a public-key signature, where one side signs and anyone can verify.
Does an HMAC encrypt the message? No. An HMAC authenticates the message; it does not hide it. The message travels and is stored in plain readable form, and the signature sits alongside it as proof. If you need the content kept secret, that is a separate job for encryption.
Why does the tool not offer HMAC-SHA-1 or HMAC-MD5? The generator offers SHA-256, SHA-384 and SHA-512 only. The weaker pairings are deliberately omitted, because there is no good reason to build a new signature on a hash that has already been shown to be breakable.
Why did my HMAC not match the one I expected? A mismatch is almost always byte-level. A trailing newline at the end of the message, a different text encoding, a hex key pasted and treated as plain text or the reverse, or JSON that was re-serialised instead of signed as the raw bytes it arrived in. Check the exact bytes on both sides before suspecting the key.
Conclusion
The secret key is the whole story: it turns a fingerprint anyone can copy into a signature only a key holder can produce. When a message needs to prove where it came from, reach for the HMAC Generator, not a plain hash, and keep the bytes exact. If you are on the receiving end, our companion guide on verifying a webhook signature with HMAC walks through the checking side. For more in this series, see our Security and Privacy guides.
References
- RFC 2104, HMAC: Keyed-Hashing for Message Authentication: https://www.rfc-editor.org/rfc/rfc2104
- NIST FIPS 198-1, The Keyed-Hash Message Authentication Code (HMAC): https://csrc.nist.gov/pubs/fips/198-1/final