FormatterHQ

HMAC Generator

Generate HMACs — keyed message authentication codes — with SHA-256, SHA-512, SHA-3 and other hashes. Keys can be text, hex or Base64; output hex or Base64.

Loading tool…
Ready.

How to use the HMAC Generator

  1. Type or paste text into the input box, or switch the source to File and choose a file — it is hashed locally, never uploaded.
  2. Choose the Hash, Secret key, Key format and Output settings. HMACs with every supported hash function are listed, with your chosen one first.
  3. To verify a value, paste it into Compare with an expected hash — the tool reports a match, or which algorithm it matches instead. Copy any row with its Copy button.

HMAC generator for signing and verifying messages

HMAC (hash-based message authentication code, RFC 2104) combines a secret key with a hash function to produce a tag that proves a message came from someone who knows the key and was not changed on the way. This HMAC generator computes HMACs with nine hash functions, text, hex or Base64 keys, and hex or Base64 output — exactly what you need to debug webhook signatures or API request signing.

Example

Message The quick brown fox jumps over the lazy dog, key key, HMAC-SHA256:

f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8

The same HMAC in Base64 is 97yD9DBThCSxMpjmqm+xQ+9NWaFJRhdZl0edvC0aPNg=. Many APIs send signatures in Base64, others in hex — the value is the same, only the encoding differs.

How HMAC works

HMAC hashes the message twice with two keys derived from your secret: HMAC(K, m) = H((K ⊕ opad) ‖ H((K ⊕ ipad) ‖ m)). Keys longer than the hash block size are hashed first; shorter keys are padded with zeros. This nested construction is what makes HMAC safe even with hash functions like SHA-256 that are vulnerable to length-extension attacks when used naïvely as H(key + message).

HMAC vs a plain hash

Hash (e.g. SHA-256)HMAC
Needs a keyNoYes
Anyone can compute itYesOnly key holders
Proves integrity against attackersNo — an attacker can recompute itYes
Proves who sent itNoYes, among parties sharing the key

Where you will use HMAC

  • Webhooks. GitHub sends X-Hub-Signature-256: sha256=<hex HMAC> of the raw request body; Stripe, Shopify and Slack use HMAC-SHA256 schemes with their own header formats and, often, a timestamp included in the signed data.
  • API request signing, such as AWS Signature Version 4, which chains several HMAC-SHA256 operations.
  • JSON Web Tokens with the HS256, HS384 or HS512 algorithms — see the JWT Decoder.
  • One-time passwords: TOTP and HOTP are built on HMAC-SHA1 by default.

Debugging signature mismatches

  1. Sign the exact raw bytes the sender signed. Re-serialising parsed JSON changes whitespace and key order and breaks the signature.
  2. Use the right key format: many providers show secrets as hex or Base64 — choose the matching Key format instead of pasting them as text.
  3. Match the output encoding and any prefix (such as “sha256=”).
  4. Check whether the provider signs extra data, such as a timestamp joined to the body.

In application code, compare signatures with a constant-time function (for example crypto.timingSafeEqual or hmac.compare_digest) to avoid timing attacks.

Choosing the hash

HMAC-SHA256 is the standard choice. HMAC-SHA512 and HMAC-SHA3 are fine alternatives. HMAC-MD5 and HMAC-SHA1 are not broken as MACs in the way MD5 and SHA-1 are as hashes, but they are legacy options — use them only for compatibility. The HMAC is computed in your browser, and the key and message are not sent anywhere while you work. A Save & Share link is different: it stores the message and the form settings, including the secret key, on our server, so clear the key first if it is a real one — and avoid pasting production secrets into any website. For unkeyed hashes, see the SHA-256 Hash Generator.

Frequently asked questions

What is the difference between HMAC and a hash?
A hash can be computed by anyone from the message alone. An HMAC also requires a secret key, so it proves the message was created or approved by someone who holds that key.
Why does my webhook signature not match?
The most common causes are signing parsed-and-reserialised JSON instead of the raw body, using the secret in the wrong format (text vs hex or Base64), or comparing hex with Base64.
Is HMAC-SHA1 still secure?
HMAC-SHA1 is still considered secure as a MAC and is used by TOTP. New systems should nevertheless use HMAC-SHA256 or stronger.
How long should an HMAC key be?
At least as long as the hash output — 32 random bytes for HMAC-SHA256 — and generated with a secure random source.
Can I verify an HMAC without the key?
No. Verifying requires computing the HMAC again with the same key, which is the point of a MAC.

Last updated October 3, 2026

Related tools

Htpasswd Generator Create .htpasswd entries for Apache and Nginx basic auth with bcrypt, APR1-MD5 or SHA-1 — one username:password per line. Keccak Hash Generator Generate original Keccak-224/256/384/512 hashes, including the Keccak-256 used by Ethereum and Solidity. MD2 Hash Generator Generate the MD2 hash of any text or file online. Instant 128-bit digest in hex, computed in your browser. MD4 Hash Generator Generate the MD4 hash of any text or file online. Instant 128-bit digest in hex, computed in your browser. MD5 Hash Generator Generate the MD5 hash of any text or file online. Instant 128-bit digest in hex, computed in your browser. NTLM Hash Generator Generate the Windows NTLM (NT) password hash — MD4 of the UTF-16LE password — online. Password Strength Checker Estimate password entropy and crack time for online and offline attacks, and spot common patterns — checked privately in your browser. PBKDF2 Hash Generator Generate PBKDF2-HMAC-SHA256/512 derived keys and Django-style password hashes with your own salt and iteration count, using WebCrypto. RIPEMD-160 Hash Generator Generate the RIPEMD-160 hash of any text or file online. Instant 160-bit digest in hex, computed in your browser. RSA Key Pair Generator Generate RSA 2048, 3072 or 4096-bit public/private key pairs in PEM (PKCS#8, PKCS#1) or JWK format with WebCrypto, entirely offline. Scrypt Hash Generator Derive scrypt password hashes and keys with custom N, r, p and salt; output as hex, Base64 and common encoded formats. Self-Signed Certificate Generator Create a self-signed SSL/TLS certificate and RSA key for localhost, dev servers or internal tools. Generated locally with WebCrypto.