Skip to content
ToolZone

HMAC Generator

Generate a keyed HMAC hash using a secret key combined with your message, used to verify both integrity and authenticity, common in API auth.

Runs in your browser. Nothing you enter or upload leaves your device.

HMAC-SHA-256 · Hex
Enter a secret key
HMAC-SHA-256 · Base64
Enter a secret key
HMAC-SHA-256 · Base64 URL-safe
Enter a secret key

Signed in your browser with Web Crypto; the key and message never leave this page. An empty message is valid.

Keyboard shortcuts

Run the main action
⌘ / Ctrl + Enter
Copy the result
⌘ / Ctrl + Shift + Enter
Download the result
⌘ / Ctrl + S
Paste a file or image into file tools
⌘ / Ctrl + V
Search all tools
⌘ / Ctrl + K
Show these shortcuts
?

You can also drop files anywhere on the page.

About the HMAC Generator

The HMAC Generator computes a keyed hash of a message, the kind of signature APIs and webhooks use to prove a request came from someone who knows a shared secret. Enter the message and key, pick the hash algorithm, and copy the hex result.

How it works

HMAC (RFC 2104) combines a secret key with a hash function. The key is padded to the hash's block size and mixed with two fixed constants to make an inner and an outer key. The message is hashed with the inner key, and that result is hashed again with the outer key. The double hashing protects against length-extension attacks that affect a naive hash(key + message).

This tool reads the key as UTF-8 text, hex or Base64, encodes the message as UTF-8, imports the key into crypto.subtle with the selected hash and calls the sign operation. The result is shown as hex (40 characters for SHA-1, 64 for SHA-256, 96 for SHA-384, 128 for SHA-512), as Base64 and as URL-safe Base64. An empty message is valid, so only a key is required.

How to use

  1. 1

    Paste the message or request body into the message box.

  2. 2

    Enter the shared secret and say whether it is text, hex or Base64.

  3. 3

    Choose the hash; SHA-256 is selected by default.

  4. 4

    Copy the HMAC in the format you need, or paste a received signature to verify it.

Worked examples

Signing a query string

You want the expected signature for a test request.

Input
Message: order_id=1001&amount=49.99 Key: my-secret-key Algorithm: SHA-256
Result
a6900644f9eb7a5860fe3afa7cf3e9356b1f62201c7195d94f75cc768429fdac

Same message, different algorithm

A legacy partner still uses HMAC-SHA1.

Input
Message: order_id=1001&amount=49.99 Key: my-secret-key Algorithm: SHA-1
Result
46a8d7144879d00585ab69d62104d01e34faa1a5

The output is shorter (40 hex characters) and unrelated to the SHA-256 version.

Limitations
Only SHA-family hashes are available; MD5 and SHA-3 aren't. The message is always encoded as UTF-8 text; binary messages can't be pasted.
Assumptions
Message and key are UTF-8 text.
Privacy
The message and secret key are processed by your browser's Web Crypto API and are not sent to a server or stored.

Frequently asked questions

How is HMAC different from a regular hash?+

A regular hash can be computed by anyone, so it only detects accidental changes. An HMAC also requires the secret key, so a matching HMAC shows the sender knew the key and the message was not altered.

Where is HMAC commonly used?+

Signing webhooks and API requests, building signed URLs, verifying cookies and session data, and inside JWTs that use the HS256, HS384 or HS512 algorithms.

Why does my HMAC not match the one my provider sent?+

Common causes are a modified body (re-serialized JSON, changed line endings), a missing timestamp or prefix in the signed string, a wrong secret or key encoding, or a signature prefix such as sha256= left in the verify box.

Is HMAC-SHA1 still safe?+

HMAC-SHA1 is not affected by SHA-1 collision attacks in the same way plain SHA-1 is and is still considered acceptable for message authentication, but HMAC-SHA256 is recommended for new systems.

How long should my secret key be?+

At least as long as the hash output: 32 random bytes for HMAC-SHA256 is a common choice. Short, guessable keys can be brute-forced.

Related tools