Advanced HMAC Generator
Compute and verify HMAC-SHA-256, SHA-384, SHA-512 and SHA-1 for text and files, with text, hex or Base64 keys and a random key generator.
100% client-side · Web Crypto API · Your key and data are never stored or sent
HMAC authenticates data, it does not encrypt it. Use throwaway keys for testing and never paste a production secret into any website.
How HMAC Works
HMAC turns a hash function into a keyed one. The key is padded to the hash's block size and XORed with two constants, ipad (0x36 repeated) and opad (0x5c repeated). The message is hashed together with the first padded key, and that result is hashed again with the second: HMAC(K, m) = H((K ⊕ opad) || H((K ⊕ ipad) || m)). Anyone who knows the key can recompute the code and check it; anyone who does not cannot forge one, and a single changed bit in the message gives an unrelated code.
This page uses your browser's built-in HMAC implementation (the Web Crypto API) rather than hand-written code, and you can check it against the published RFC 4231 example with one click.
Native Web Crypto
HMAC-SHA-256, SHA-384, SHA-512 and SHA-1 computed by the browser itself
Text, Hex or Base64
Set how the key and the message are read, to match your API exactly
Random Key Generator
Creates a key of the recommended length from cryptographically secure random bytes
Signature Checking
Verify webhook-style signatures, with a constant-time comparison
Real Key Guidance
Judges your key against the length each algorithm recommends
Nothing Stored
Your key is masked, never saved, and there is no history
Explore more free tools in our security tools collection, including our strong random password generator.
Frequently Asked Questions
1. What is HMAC?
HMAC (Hash-based Message Authentication Code) proves that a message came from someone who knows a shared secret key and was not changed on the way. It is defined as HMAC(K, m) = H((K ⊕ opad) || H((K ⊕ ipad) || m)): the key is mixed in twice, in an inner and an outer hash, using two fixed padding constants. It is used to sign API requests, verify webhooks, protect cookies and sessions, and in JWTs (HS256, HS384, HS512). HMAC authenticates a message; it does not encrypt it.
2. Why not just hash the key and the message together?
Because plain hashes like SHA-256 and SHA-512 are vulnerable to length-extension attacks: given SHA-256(key + message) and the message length, an attacker can compute a valid hash for the message plus extra data without knowing the key. HMAC's nested structure is designed to prevent exactly that, which is why you should always use HMAC rather than inventing your own keyed hash.
3. Which hash algorithm should I choose?
HMAC-SHA-256 is the usual default and what most services expect. SHA-384 and SHA-512 give longer outputs and are used where a service specifies them. HMAC-SHA-1 is still considered secure, because the collision attacks that broke SHA-1 do not apply to HMAC, but it is best avoided in new designs and kept only for compatibility. MD5 is not offered. Always use the algorithm the other side specifies, since different algorithms give completely different results.
4. How long and how random should the key be?
Use a random key at least as long as the hash output: 32 bytes for SHA-256, 48 for SHA-384 and 64 for SHA-512 (RFC 2104). Longer keys do not add strength beyond the hash size, because a key longer than the hash's block size is hashed first. A key made from a human-chosen password is only as strong as that password, so use the Generate random key button, which fills the key with random bytes from the Web Crypto API, and store the key in a secret manager rather than in code.
5. Why does my HMAC not match the one from an API or library?
The result depends on exact bytes, so the most common causes are: the key being interpreted differently (as text instead of hex or Base64, or the other way round), a trailing newline or different line endings in the message, a different text encoding (this tool uses UTF-8), JSON that was reformatted before signing, a different algorithm, or comparing a hex result with a Base64 one. Set the key and message formats to match how the other side treats them, and try the RFC 4231 example button to confirm the tool itself agrees with the standard.
6. How do I verify a signature, such as a webhook?
Enter the same key and the exact message body, then paste the signature you received into the verify box. It accepts hex or Base64 (standard or URL-safe) and ignores a leading sha256=-style prefix, as used by GitHub webhooks. The comparison is done with the browser's constant-time verify function. In your own code, always compare signatures with a constant-time function rather than ==, and check a timestamp or nonce so an old signed message cannot be replayed.
7. Is it safe to use real secrets here? Are my keys stored or sent?
Everything runs in your browser with the Web Crypto API, the page's content security policy blocks outgoing network requests, and nothing is saved: there is no history and no local storage, and the key box hides your key by default. Even so, the safest habit is to test with throwaway keys and never paste a production secret into any website. Files are limited to 256 MB because the browser's HMAC function needs the whole file in memory.
8. What happens if my browser does not support the Web Crypto API?
The tool shows a warning and disables itself rather than falling back to weaker, hand-written cryptography. The Web Crypto API needs a modern browser and a secure (HTTPS) page. One more limit to know: the browser's HMAC function does not accept an empty key, so the tool asks for a key with at least one byte.