HMAC Calculator
Generate HMAC-SHA256, HMAC-SHA384, HMAC-SHA512, and HMAC-SHA1 message authentication codes using the Web Crypto API
Paste your message and secret key, pick an algorithm (SHA-256, SHA-384, SHA-512, or SHA-1), and get the HMAC output in hex or Base64 — no throwaway scripts, no openssl installs. Keys accept UTF-8 text, hex, or Base64, so you skip the format conversion step entirely. And everything runs in your browser. Nothing gets uploaded.
How It Works
HMAC works by combining your message with a secret key inside a hash function — twice, actually. The key gets padded, XOR’d with two different constants, then hashed around the message. The result is a fixed-length code that only someone with the same key can reproduce. That’s what makes it useful for verifying both who sent a message and whether it was changed in transit.
Examples
Verifying a Stripe Webhook Signature
Stripe signs every webhook payload with HMAC-SHA256 using your endpoint secret. You need the hex digest to compare.
Message: {"id":"evt_1234","type":"charge.succeeded"}
Key: whsec_test123abc
Algorithm: HMAC-SHA256
Hex: a1b2c3d4e5f6...
Base64: obLD1OX2...
Signing an AWS API Request
AWS Signature Version 4 uses a chain of HMAC-SHA256 operations. Quick sanity check: does the intermediate signing key match what you expect?
Message: 20260331
Key: AWS4wJalrXUtnFEMI
Algorithm: HMAC-SHA256
Hex: 7f3e2a9c...
(compare against your code output)
Generating a JWT Signature by Hand
JWTs signed with HS256 are just HMAC-SHA256 of the header.payload string. Useful when you want to verify a token without a library.
Message: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0
Key: my-jwt-secret
Algorithm: HMAC-SHA256
Base64: SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
(this becomes the third segment of the JWT)
Who Uses This
Debugging webhook signatures, API auth headers, and JWT tokens during integration work.
Validating HMAC implementations in code reviews and penetration tests without spinning up a dev environment.
Checking AWS Signature V4 intermediate values and verifying CI/CD webhook payloads.
Comparing hand-calculated HMAC results against a known-good implementation for coursework.
Common Mistakes
Your API docs say the key is hex-encoded, but you’re pasting it as UTF-8 text. The HMAC output will be completely different. Always match the key format dropdown to how the key was actually generated.
A trailing newline changes the hash entirely. If you copied the payload from a terminal, there’s probably a hidden \n at the end. Trim it. One invisible character is all it takes for a mismatch.
The same HMAC looks completely different in hex vs Base64. If your API returns Base64 and you’re comparing against hex, it’ll never match — even though the underlying bytes are identical.
Older docs sometimes just say "HMAC" without specifying the hash. Most modern systems default to SHA-256. If you’re getting mismatches, double-check which algorithm the other side actually expects.
Technical Details
- Processing: 100% client-side — uses the browser’s native Web Crypto API
- Algorithms: HMAC-SHA256, HMAC-SHA384, HMAC-SHA512, HMAC-SHA1
- Key Formats: UTF-8 text, hexadecimal, Base64
- Output Formats: Lowercase hex, uppercase hex, Base64
- Browser Support: Chrome, Firefox, Safari, Edge (all modern browsers with Web Crypto)
- Offline Capable: Yes — no network requests needed after page load
Frequently Asked Questions
What is HMAC and how is it different from hashing?
A regular hash like SHA-256 takes a message and produces a fixed-length digest. Anyone can compute it — there’s no secret involved. HMAC wraps a hash function with a secret key, so only someone who knows the key can generate (or verify) the code. That’s what makes HMAC useful for authentication, not just integrity checking.
Is my secret key safe when I use this online tool?
Yes. The HMAC calculation happens entirely inside your browser using the Web Crypto API. Your key and message never leave your device — nothing gets sent to a server. You can verify this yourself: open DevTools, check the Network tab, and you’ll see zero outbound requests when you generate an HMAC.
Which HMAC algorithm should I use?
HMAC-SHA256 is the standard pick for almost everything — APIs, webhooks, JWTs, you name it. SHA-512 gives you a longer output if your protocol requires it. SHA-1 still works but it’s considered legacy. Use it only when the other side specifically demands it.
Why doesn’t this tool support HMAC-MD5?
The browser’s Web Crypto API doesn’t include MD5 at all. MD5 has known collision vulnerabilities, so browser vendors chose not to implement it. If you absolutely need HMAC-MD5 for a legacy system, you’d have to use a server-side tool or a JavaScript polyfill library.
Can I use HMAC to encrypt data?
No. HMAC is a one-way operation — it produces a fixed-length authentication code, not ciphertext. You can’t reverse an HMAC to get the original message back. If you need encryption, look into AES or a similar cipher. HMAC is for proving a message is authentic and unmodified, not for hiding its contents.