Security

HMAC Generator & Verifier

Generate an HMAC signature or check one, with HMAC-SHA-1, SHA-256, SHA-384 and SHA-512. The message and secret are computed locally and are never sent, stored or put in the URL.

Guide: HMAC vs Hash: Generate and Verify an HMAC-SHA256

HMAC = integrity/authentication primitive, not encryption. An HMAC proves a message was not changed and was produced by someone holding the secret. It does not hide the message, and it cannot be turned back into it.

Checking which algorithms this browser supports.

Hex
Base64
Base64url
Ready.

What it does

HMAC (Hash-based Message Authentication Code, RFC 2104) combines a hash function with a secret key. Anyone holding the same key can recompute the code and confirm that a message is unchanged and came from a key holder. It is used to sign webhooks, API requests and tokens such as HS256 JWTs.

HMAC is not encryption

HMAC = integrity/authentication primitive, not encryption. The message stays readable; the HMAC only travels alongside it as proof. To keep data secret you need real encryption, and HMAC is not a way to store passwords either (use bcrypt, scrypt or Argon2).

Using the tool

  • Generate: enter a message and a secret, pick an algorithm, and copy the result as hex, Base64 or Base64url.
  • Verify: paste the HMAC you were given. Hex and Base64 are detected automatically. The result is valid or invalid, and if the value matches a different algorithm the tool tells you which one.
  • Encodings: the message and the secret each have their own selector, and the line under the fields shows exactly how each is read and how many bytes it becomes. A binary key must be entered as Hex or Base64, not as text.

Test it

Known results for HMAC-SHA-256 you can check against:

  • Secret key, message The quick brown fox jumps over the lazy dog:
    f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
  • Empty secret and empty message:
    b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad

A trailing newline changes the result, so a mismatch with a command-line check is often a line break.

Security and privacy

  • The secret and message are processed only in this page with the browser Web Crypto API. Nothing is uploaded, and there is no analytics.
  • They are never placed in the URL and are never saved in localStorage, cookies or any other storage. The secret field is cleared when you leave the page.
  • Verification compares the two values byte by byte over the full length, without stopping at the first difference. In a browser this is a best-effort measure; for production verification use your server platform's constant-time comparison.
  • Algorithms are tested on your browser at load time, and any that it does not provide are disabled.

Related

For plain digests of text or files use the Hash Generator. HS256, HS384 and HS512 JWTs are HMAC signatures: build them with the JWT Generator or check them with the JWT Decoder. Convert values with the Base64 tool, and create strong secrets with the Password Generator.

A test you can verify yourself

With the secret key and the message The quick brown fox jumps over the lazy dog the tool produces these well-known test values:

  • HMAC-SHA-256 (hex): f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
  • HMAC-SHA-1 (hex): de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9

SHA-256, SHA-1, SHA-384 and SHA-512 are available, and the result is shown as hexadecimal, Base64 and Base64URL.

Verify mode

Switch to Verify, paste the code that you received, and the tool compares it with the one it calculates. If the expected value is correct, the result is “VALID — the expected value matches the HMAC-SHA-1 of this message and secret”, and it says how the expected value was read (hex, 20 bytes). Change one character and it reports that it does not match and reminds you to check the message, the secret and how each is encoded. Most mismatches come from different encodings of the key or message, or from a trailing newline.

Frequently asked questions

What is the difference between HMAC and a plain hash?

A hash has no key, so anyone can compute it. An HMAC needs the secret key, so only holders of the key can create or check it. The Hash Generator makes plain hashes.

Is HMAC-SHA-1 still safe?

The tool notes that HMAC-SHA-1 is still considered safe as a message authentication code, but recommends HMAC-SHA-256 or stronger for new designs.

How should my server compare the codes?

With a constant-time comparison function from your language or crypto library, not with a normal string comparison, so that timing does not reveal how many characters were right.

Does my secret leave the browser?

No. The calculation uses your browser’s crypto functions and nothing is uploaded.

Share this tool

Your data is not included in this link.