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
Paste the message or request body into the message box.
- 2
Enter the shared secret and say whether it is text, hex or Base64.
- 3
Choose the hash; SHA-256 is selected by default.
- 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.
Same message, different algorithm
A legacy partner still uses HMAC-SHA1.
The output is shorter (40 hex characters) and unrelated to the SHA-256 version.
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.