Compute HMAC digests from text + secret key
Choose a hashing function and output encoding, then copy the HMAC instantly — all in your browser

The HMAC Generator computes a hash-based message authentication code from a plaintext message and a secret key. Unlike plain hashing, HMAC proves that the sender knew the secret key — which is exactly what you need for signature verification in APIs, webhooks, and internal systems.
What problems does it solve?
HMAC is for authenticating messages, not for storing passwords. For password storage, use dedicated password hashing (like bcrypt) with a per-user salt.
If you’re also working with plain digests, you may like our Hash Text tool. If you need password hashing specifically, use Bcrypt.
Paste the message
Put the exact plaintext payload you want to authenticate (for example, a webhook JSON body).
Enter the secret key
This is your shared secret. Keep it private and prefer a long, random key.
Choose hashing function + output encoding
For modern APIs, HMAC-SHA-256 is a safe default. Choose Hex if you’re matching most docs; choose Base64/Base64URL if your system expects that.
Copy and compare
Copy the HMAC output and compare it with the signature you received (for example, an HTTP header).
Suppose you choose SHA-256 and Hex. The output is always . In hex, that becomes , so you should see exactly:
If your result is not 64 hex characters, you are probably using a different algorithm, encoding, or text normalization.
SHA-1 output is . Base64 length is:
So a Base64 HMAC-SHA-1 string is typically 28 characters (including padding).
Background: your server receives a webhook with a signature header. You want to reproduce the signature to find out why verification fails.
Inputs (example)
Message: raw request body (for example of JSON)
Secret key: shared secret (for example )
Settings: + Hex
Result: you should get a 64-character hex string. If your provider prefixes the header with, the header value length becomes:.
Background: you generate log lines that should be tamper-evident.
Inputs (example)
Message: one log line (for example )
Settings: + Base64URL
Result: Base64 is 88 characters (including padding). If you use Base64URL without padding, it is typically characters.
Background: you sign method + path + body so servers can reject modified requests.
Inputs (example)
Canonical string length: (method + path + timestamp + body)
Settings: + Base64
Result: Base64 output is 44 characters (often with one padding character). If your API expects Base64URL without padding, it is commonly 43 characters.
Background: you need a compact signature string to attach to a payload.
Base64URL is often the best transport format.
If you switch to Binary output for SHA-256, you will see exactly bits.
If you need a random token, use Token Generator instead.
Tip for mismatches
If your server expects a prefix (like ) or expects Base64 instead of Hex, your values may look different even when the underlying bytes match.
Use HMAC to confirm a webhook body is authentic and unmodified.
Sign canonical strings to detect tampering or replay (with timestamps/nonces).
Attach a signature to each record so changes are detectable.
Compare signatures while you adjust whitespace, newline endings, or JSON formatting.
Switch between Hex/Base64/Base64URL/Binary to match what your platform expects.
Don’t use HMAC as a password hash. Use bcrypt (or a modern password hashing scheme) instead.
Choose a good key
Prefer SHA-256 or SHA-512
In new systems, is a widely supported default. Avoid MD5 for security-sensitive designs.
Use constant-time comparison in code
When verifying signatures, compare values using a constant-time function to reduce timing side-channels. This tool is for computing the expected signature; your production verification should still be careful.
Watch out for encoding differences
Pro tip: start with a known-good test vector
If you’re implementing verification in code, try an official test vector first, then switch to your real payload. This helps you isolate bugs in encoding vs cryptography.
HMAC wraps a hash function in a secure construction. You don’t need to compute it by hand, but understanding the structure helps when debugging.
Core definition
Here is the secret key, is the message, is the selected hash function, and is XOR.
Output size and encodings
The HMAC output length equals the underlying hash digest length. For example, for SHA-256:
Base64 length is for bytes.
Variable glossary
HMAC vs plain hash
A plain hash (like SHA-256) is great for checksums, but anyone can compute it. HMAC adds a secret key, so only trusted parties can produce the correct value.
Transport format: Hex vs Base64
Hex uses only and is easy to read. Base64 is shorter. Base64URL is URL-safe.
What HMAC does not protect against
The top causes are: different encoding (Hex vs Base64), different newlines, different JSON formatting, or a missing prefix. Ensure both sides sign the exact same byte sequence.
No. HMAC provides integrity and authenticity, not secrecy. If you need confidentiality, encrypt the message (for example, with AES) and then authenticate it.
For new designs, is a good default. If you need shorter outputs, consider SHA-1 only for legacy compatibility.
Base64URL replaces characters to be URL-safe and often drops padding. It represents the same bytes, just with a different alphabet.
You shouldn’t. This page intentionally shares configuration but never includes the secret key.
Because the digest size is fixed. For SHA-256, it’s . In Hex that’s characters.
Security disclaimer
This calculator runs locally in your browser, but you should still avoid pasting production secrets on shared machines. Use it primarily for development and debugging.
Not a substitute for professional review
Cryptographic design choices depend on threat models and operational constraints. For production systems, consult established standards and security guidance.
Use a simple chronometer (stopwatch) to track elapsed time down to milliseconds. Runs locally in your browser.
Normalize email addresses to a standard format for easier comparison. Useful for deduplication and data cleaning. Runs locally in your browser.
Estimate the time needed to consume a total amount at a constant rate, and get an expected end time. Runs locally in your browser.
Parse and decode your JSON Web Token (JWT) and display its content. All computation runs locally in your browser.
Know which file extensions are associated to a MIME type, and which MIME type is associated to a file extension. Includes a full MIME types table.
Generate random Lorem Ipsum placeholder text with customizable paragraphs, sentences, and word counts. Runs locally in your browser.