HMAC Generator — Keyed Message Authentication
This free HMAC generator computes a keyed-hash message authentication code (HMAC) from a message and a secret key, directly in your browser. HMAC is the standard way to prove that a message came from someone who holds the shared secret and was not altered in transit — it is what signs and verifies webhooks (Stripe, GitHub), AWS Signature requests, API calls, and session tokens.
Choose HMAC-SHA-256 (the default and most widely used), SHA-1, SHA-384, or SHA-512, supply your secret as UTF-8 text or as raw hex bytes, and read the digest in both lowercase hexadecimal and Base64. Everything is computed with the browser's native Web Crypto API (crypto.subtle), so your message and key never leave your device.
How to use HMAC Generator
- Select an algorithm — HMAC-SHA-256 is the recommended default.
- Type or paste the message you want to authenticate.
- Enter the secret key, and choose whether it is read as UTF-8 text or as raw hex bytes to match the system you are integrating with.
- Copy the resulting HMAC in hexadecimal or Base64 with the copy button next to each output.
What is an HMAC?
HMAC (Hash-based Message Authentication Code, RFC 2104) combines a cryptographic hash function with a secret key. Because the key is folded into the hash, only parties who know the secret can produce a valid digest for a given message — that is what makes it a message authentication code rather than a plain checksum. It provides two guarantees at once: integrity (the message was not modified) and authenticity (it came from a holder of the key).
Verification is symmetric: the receiver recomputes the HMAC over the received message with the same secret and checks that it matches the digest that was sent. For security, that comparison should be done in constant time so an attacker cannot learn the correct value byte by byte from timing.
HMAC-SHA-256(key = "key", message = "The quick brown fox jumps over the lazy dog") = f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
Choosing a hash algorithm
- HMAC-SHA-256 — the modern default and the right choice for almost everything: webhook signing, API request signatures, and token integrity.
- HMAC-SHA-384 / HMAC-SHA-512 — larger SHA-2 digests for a higher security margin; SHA-512 is often faster on 64-bit CPUs.
- HMAC-SHA-1 — still used by some legacy systems (older AWS signatures, TOTP two-factor codes). HMAC's security does not rely on the hash's collision resistance, so HMAC-SHA-1 is not broken the way raw SHA-1 collisions are — but prefer SHA-256 for anything new.
- HMAC-MD5 is not offered: the Web Crypto API does not implement it, and MD5 should be avoided for new work.
Key encoding: UTF-8 vs hex
The same key text produces different digests depending on how its bytes are derived, so the encoding must match the other side exactly. Most APIs hand you a plain secret string (for example a Stripe whsec_ value) — use UTF-8 text. Some systems specify the key as a hex-encoded byte string; select Hex so that, for example, 48656c6c6f is read as the five bytes of "Hello" rather than the ten literal characters.
If two systems disagree on the digest, an encoding mismatch is the usual cause: a UTF-8-vs-hex key difference, a different message encoding, a stray trailing newline in the message, or a different hash algorithm.
Related terminology
- HMAC
- Hash-based Message Authentication Code — a keyed hash (RFC 2104) that proves a message's integrity and authenticity to holders of the shared secret.
- MAC
- Message Authentication Code — a short tag that authenticates a message; HMAC is the most common construction.
- Secret key
- The shared secret mixed into the hash. Anyone with it can create or verify a valid HMAC, so it must be kept private.
- Digest
- The fixed-length HMAC output, shown here as lowercase hexadecimal or Base64.
- Constant-time comparison
- Comparing two HMACs in a way whose timing does not depend on where they first differ, to defeat timing attacks during verification.
Frequently asked questions
- Is an HMAC the same as encryption?
- No. HMAC provides integrity and authenticity, not confidentiality — it is a keyed checksum, not a cipher. The message is not hidden or scrambled; anyone can read it, but nobody can forge a valid HMAC without the secret key. Use encryption if you need to keep the message itself private.
- Which algorithm should I use?
- HMAC-SHA-256 for almost everything — it is the widely adopted standard for webhooks, API signing, and token integrity. Use SHA-384 or SHA-512 for a larger security margin, and HMAC-SHA-1 only when a legacy protocol requires it.
- Why does my HMAC differ from the one my server computes?
- The two sides must agree on every input. Check that you selected the same hash algorithm, the same key encoding (UTF-8 vs hex), and the exact same message bytes — a trailing newline or a different character encoding changes the digest completely.
- Can this tool compute HMAC-MD5?
- No. The browser's Web Crypto API implements HMAC only over the SHA-1 and SHA-2 families, so HMAC-MD5 is unavailable here. That is fine for new work, since MD5 is deprecated — use HMAC-SHA-256 instead.
- Is my secret key sent anywhere?
- No. The key and message are processed entirely in your browser with the native Web Crypto API (crypto.subtle). Nothing is uploaded, logged, or stored — you can confirm with your browser's network tab.
- Should I use the hex or the Base64 output?
- Whichever the receiving system expects. Hex (lowercase) is common for webhook signature headers; Base64 is common in HTTP Authorization headers and some AWS-style signatures. The two encode the identical digest bytes.