HMAC
Compute a Hash-based Message Authentication Code (HMAC) of a message using a shared key and a chosen hash algorithm.
HMAC-SHA256 test vector
Use this pair to confirm that your own code computes the same value as this tool:
key key
message The quick brown fox jumps over the lazy dog
algorithm SHA-256
f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
The output length depends only on the hash function: SHA-256 gives 64 hex digits (32 bytes), SHA-1 gives 40, SHA-384 gives 96, SHA-512 gives 128 and MD5 gives 32. Changing one character of the key or of the message changes the whole value.
Why a webhook signature does not match
- The body was re-serialised. The sender signs the exact bytes of the request body. Parsing the JSON and writing it out again changes spacing and key order. Sign the raw body.
- A trailing newline. A message copied from a file or a terminal often ends with a line break that the sender did not sign.
- The key encoding. Some services give the secret as hex or Base64 and expect it to be decoded to bytes first; others use the string as it is. This tool uses the key as UTF-8 text.
- The output encoding. The same HMAC is 64 hex digits or 44 Base64 characters. Compare
like with like, and ignore a prefix such as
sha256=. - The signed string has more parts. Many schemes sign a timestamp joined to the body,
for example
timestamp.body, not the body alone.
Compare signatures in constant time in production code; a plain string comparison leaks how many leading characters were correct.
Related tools
Monitor HMAC automatically
Compute a Hash-based Message Authentication Code (HMAC) of a message using a shared key and a chosen hash algorithm. NetTests can run this check on a schedule, preserve historical results, compare changes over time, and alert you the moment something breaks.
Start monitoring free → See all monitoring productsFrequently Asked Questions
What is HMAC?
Hash-based Message Authentication Code (HMAC) combines a message with a secret key and a hash function to produce an authentication code. Unlike a plain hash, HMAC requires knowing the secret key to verify — so it authenticates both the message content and the sender's identity. The formula is HMAC = H(key ⊕ opad || H(key ⊕ ipad || message)).
How is HMAC different from a plain hash?
A plain hash (Secure Hash Algorithm 256 (SHA-256) of 'hello') is publicly reproducible by anyone — it authenticates nothing. HMAC adds a secret key so only parties who know the key can produce or verify the code. An attacker who sees the message and HMAC cannot forge a valid code for a different message without the key.
What is HMAC used for?
Common uses: signing Application Programming Interface (API) requests (AWS Signature v4, Stripe webhooks, GitHub webhook verification), generating Cross-Site Request Forgery (CSRF) tokens, creating signed cookies, and verifying JSON Web Token (JWT) signatures using the HS256/HS512 algorithm. Any scenario where two parties share a secret and need to verify message integrity is a candidate for HMAC.
Which HMAC algorithm should I choose?
HMAC-SHA-256 is the standard choice — widely supported, secure, and produces a 256-bit (32-byte) Message Authentication Code (MAC). HMAC-SHA-512 is faster on 64-bit systems and provides a larger output. Avoid HMAC-MD5 and HMAC-SHA-1 for new systems — while their HMAC modes are technically stronger than plain MD5/SHA-1, SHA-256 is the current standard.