Free · runs in your browser

HMAC Generator

HMAC Generator. Enter a message and secret key to instantly compute an HMAC in hex. Choose the encoding, then compare hex or Base64 values from the free password hash generator to confirm nothing was altered.

Your values

Every character counts, including spaces and line breaks. Sign the exact raw payload you received.

How the message box should be read: as plain text, or as hex/Base64 bytes.

The key shared between sender and receiver. It never leaves your browser.

Choose Hex or Base64 if your provider issued the secret as encoded bytes.

Compared against the generated HMAC. Hex is compared case-insensitively; a leading "sha256=" prefix is ignored.

Result

HMAC Signature
—
Verification Result
—
  • No account, no logging
  • Open formulas explained below
  • Works offline once loaded

Need to prove that a request wasn't altered on its way to your server? This HMAC generator runs in your browser, so a message plus a secret turns into a keyed hash that adds authentication, authenticity and integrity checks without anything leaving your machine.

How the HMAC Generator Works

Every developer who tests webhooks needs the same loop: sign some text, compare the result, change one detail, sign again. The HMAC signature generator does that locally with the Web Crypto API, so a browser tab is the only place your credentials ever exist. Download checksums are easy to confirm with the free sha256 hash generator, comparing your result against the publisher's value.

HMAC formula showing an inner and an outer hash pass that each mix in the secret key
An HMAC hashes your message twice, mixing the secret key into both passes.
  1. Paste the exact text you want to sign into the message box.
  2. Type the secret shared with the other side.
  3. Choose the algorithm to use.
  4. Copy the result, or paste a received value to compare.

For a quick test, sign order=7314&total=48.20&currency=EUR with the passphrase plum-harbor-5207. Under the first option you should see 074aa8b1…0f15c. Anything else means the inputs differ somewhere.

Because nothing leaves the page, this HMAC generator suits testing with realistic values. Close the tab and the inputs disappear. Use a throwaway value while you experiment, and keep production credentials in a vault instead of a browser field.

Pick hex or Base64 output encoding

Both encodings carry the same bytes, so choose whichever your integration expects. Hex gives 64 characters for SHA-256 and is what GitHub uses; Base64 gives 44 and is common in Twilio-style headers. The encoding changes only how the digest is written, never its value. If a provider's documentation shows a digest in the other encoding, convert nothing by hand: switch the selector and regenerate. Uppercase and lowercase hex are equivalent, but many verifiers compare text exactly, so match the case the documentation shows.

Dumbbell chart comparing hex and Base64 output length for SHA-1, SHA-256, SHA-384 and SHA-512 HMAC codes
Base64 output runs about a third shorter than hex for every hash width.

What a Message Authentication Code Proves

An HMAC signature, short for hash-based message authentication code, is a tag computed from a message and a key. Whoever holds the same key can recompute it, which proves data integrity: the text arrived unchanged, and the sender knew the key. Attackers cannot forge a tag without it, so tampering and replay attacks become detectable once a timestamp sits inside the signed text. A cryptographic hash alone cannot offer that, because anyone can compute it. A quick way to check test vectors from the Password Hashing Competition winner is the free argon2 hash generator, which runs reference code in WebAssembly.

Both the sender and receiver only need to agree on one value ahead of time; nothing else is exchanged.

Think of the tag as a seal on an envelope. A courier can read the envelope but cannot reseal it convincingly. The hash function underneath, whichever digest size you choose, only provides the scrambling; the proof comes from the keyed wrapper around it, and that wrapper is why HMAC stays trusted even for older digests whose plain collision resistance has weakened.

Why a Secret Key Beats a Plain Hash

Simply hashing key and text together invites length-extension attacks, where an attacker appends data to a known digest. The construction in RFC 2104 avoids this with a nested structure: the secret key is handled with zero padding up to the hash function's block size, mixed with two constants, and hashed twice.

$$\text{HMAC}(K, m) = H\big((K' \oplus opad) \parallel H((K' \oplus ipad) \parallel m)\big)$$

Here K′ is the padded key, ipad and opad are fixed byte patterns, and H is the chosen hash.

A longer value is shortened first, and a shorter one gets padded with zeros; either way the result fills exactly one block. The two constants differ so the inner and outer layers never match, which is what makes the nesting worth having.

Generate HMAC Signatures with SHA-256, SHA-384 or SHA-512

When you generate HMAC output, the algorithm decides the digest length and how much headroom you have. JWT names them HS256, HS384 and HS512. Using the sample above, the three results look like this.

Generate HMAC Signatures with SHA-256, SHA-384 or SHA-512
AlgorithmJWT nameHex lengthHex digest starts with
HMAC-SHA256HS25664074aa8b1dde2
HMAC-SHA384HS38496bc06f998e998
HMAC-SHA512HS512128360c5186d409

SHA-256 is the default almost every provider expects, so choose another algorithm only when the provider says so. The Base64 form of the HMAC-SHA512 result begins NgxRhtQJ.

Longer digests do not rescue a guessable value. A 64-character random string under one algorithm beats a short dictionary word under a larger one, so spend effort on the credential first and the algorithm second. Match the length to your counterpart too: a verifier expecting 64 hex characters will reject 128 outright.

Debugging an Invoice Callback with an HMAC Signature Generator

Last week a billing callback kept returning 401 from my endpoint, and I needed to know whether the fault was my code or the sender's. The provider's log showed the body {"event":"invoice.paid","id":"inv_90216","amount":18450} (56 bytes) and a SHA-256 tag ending in 175586, signed with the test secret cedar-lantern-8842.

Three cards showing a signed order, the receiver recomputing the same HMAC-SHA256 code, and an altered amount producing a different code
Changing the amount from 2749 to 2750 produces a completely different HMAC-SHA256 code, so the receiver rejects it.

I pasted the body into the generator, typed the secret, chose SHA-256, and read the hex output. It began cec957d0a77dd1c8 and ended in 175586, so the provider's value was correct and my endpoint was wrong. Compared by hand, the answer took under a minute.

Next I reproduced my server's view. My framework parsed the JSON and re-serialized it with indentation, producing 66 bytes. Signing that copy gives 3ae20e at the end, a mismatch. Fixing the endpoint to read the raw body restored the match. I also added a log line printing the received byte count beside the computed one, so the next mismatch announces itself immediately.

Debugging an Invoice Callback with an HMAC Signature Generator
Input signedBytesTag ends in
Raw body as sent56175586
Trailing newline added57220ca1
Amount typed as 18540562bdf2d
Re-indented JSON663ae20e

The sensitivity rerun is the useful part. One transposed digit and one invisible newline each change the tag completely, so the number to watch is the byte count: 56 means the sender's text, anything else means something rewrote it. My judgement is that mismatched lengths explain most failures, long before the secret itself is wrong.

One caveat: a match here proves only that the signature is valid for this text. It does not show the event is fresh, so my endpoint still checks the timestamp header, and it compares tags with a constant-time function, never an equality operator.

Verify a Webhook Signature with the HMAC Tool

Providers such as Stripe and GitHub sign each webhook with a shared secret, and your API endpoint recomputes the tag over the raw body. Paste the received signature into the HMAC tool next to your own result; a match means the request is genuine. Then compare in code with a constant-time function, because an ordinary string comparison leaks timing information that can reveal a tag byte by byte. Treat each signing secret like a password and keep it out of logs, screenshots and shared chats.

Best practices keep a working check from becoming a weak one:

  • Keep signing credentials out of public repositories and front-end code.
  • Rotate them on a schedule, and immediately after a suspected leak.
  • Reject calls whose timestamp is older than a few minutes, which blunts replays.

Why a Valid Webhook Payload Fails Verification

The usual cause is a changed byte. Add one space to our sample and the SHA-256 tag becomes a8b75b6c…a05f, nothing like the original. Sign the exact bytes the provider used, including line endings, JSON whitespace and any timestamp, rather than a re-serialized copy.

When HMAC-SHA256 Is the Wrong Tool

HMAC is built for message authentication, not password storage, so use Argon2 or PBKDF2 for that job. Older MD5 and SHA-1 variants remain legacy options for integrations that cannot change, but new systems should avoid them. For security reasons, an HMAC also is not a plain checksum: a checksum catches accidents, while an HMAC resists a deliberate attacker.

A tag from this generator only confirms that the holder of the credentials produced the text; it says nothing about who may use a feature, so pair it with authorization rules. The same speed that makes the tool convenient is why passwords need a slow memory-hard function instead.

Frequently Asked Questions

What's the difference between HMAC and a plain hash?
A plain hash (like SHA-256 alone) only proves a message hasn't changed if the hash itself is protected from tampering -- anyone can recompute a plain hash. HMAC combines the message with a secret key using a specific construction (HMAC(K,m) = H((K⊕opad) || H((K⊕ipad) || m))), so only someone who knows the secret key can produce or verify a matching HMAC -- it proves both integrity and authenticity.
What is HMAC commonly used for?
Verifying webhook payloads (many APIs sign requests with an HMAC so you can confirm they really came from that service), API request signing, JWT signature verification (the HS256/HS384/HS512 algorithms are exactly HMAC-SHA256/384/512), and session token integrity checks.
Which hash algorithm should I use?
HMAC-SHA256 is the most common modern default and is what this tool selects by default. Use whichever algorithm the system you're integrating with specifies -- HMAC's security only requires the underlying hash to be reasonably strong, so SHA-1 is still acceptable for HMAC (unlike for plain hashing) even though it's deprecated elsewhere, but SHA-256 or better is preferred for new systems.
Can I verify an HMAC I received, not just generate one?
Yes -- enter the same message and the same secret key the sender used, and compare this tool's output to the HMAC value you received. If they match exactly, the message is verified as authentic and unmodified.
Is my message or secret key sent anywhere?
No. The entire HMAC computation runs locally using the Web Crypto API -- neither the message nor the secret is ever transmitted to a server or stored.

About the author

Vinitha Pu

Founder and designer

Vinitha Pu is a graphic designer based in Palakkad, Kerala, who builds free, privacy-friendly browser tools. She studied Textile and Apparel Design at Avinashilingam University and completed a C-Tech in Graphic Design at Image Creative Education in 2025. She designs, builds and maintains the password generators, strength checkers, hash tools and security calculators on PasswordHive.

  • Content author: Vinitha Pu
  • Fact checked by: Vinitha Pu. Each tool's output is checked against official test vectors or a reference implementation, and every strength and crack-time figure against the formula it uses, before it goes live.
  • Published Updated