Skip to main content
SEC

HMAC Generator

Generate HMAC signatures with custom keys

Advertisement
Advertisement

What is HMAC?

HMAC (Hash-based Message Authentication Code) creates a cryptographic signature from a message plus a secret key using a hash function such as SHA-256, SHA-1 or SHA-512. APIs use it to sign requests, webhooks use it to prove payloads were not tampered with, and token systems use it to verify authenticity. This generator computes the signature with the browser-native Web Crypto API (crypto.subtle), so the key and message never leave your device.

How to Use This Tool

  1. Type the message, Enter the text to sign (e.g. a webhook payload or API request string) in the Message box.
  2. Enter the secret key, Paste the shared secret both sides agree on into the Secret Key field.
  3. Pick the algorithm, Choose HMAC-SHA256 (best default), HMAC-SHA512 (strongest) or HMAC-SHA1 (legacy compatibility).
  4. Click Generate HMAC, The hex signature appears instantly; copy it into your Authorization header or verification script.

Understanding the Results

Algorithm echoes your choice (HMAC-SHA-256, HMAC-SHA-1 or HMAC-SHA-512). HMAC Signature is the lowercase hex digest, SHA-256 yields 64 hex characters, SHA-1 yields 40, SHA-512 yields 128. Both sides must use the identical message bytes, key bytes and algorithm or the signatures will differ; even one trailing newline changes the output completely.

Tips & Best Practices

• Prefer HMAC-SHA256 for new integrations, SHA-1 is kept only for verifying legacy systems, not new signatures.

• When a signature mismatches, compare exact bytes: check for trailing whitespace, UTF-8 vs ASCII encoding, and whether the key was base64-decoded before use.

• Never embed production secrets in screenshots of results; rotate the key if one may have been exposed.

Frequently Asked Questions

API request signing (e.g. AWS-style signatures), webhook verification (Stripe, GitHub and Slack all sign payloads this way), session tokens, and proving a message is both authentic and unmodified.

The three usual causes: a different key, different message bytes (watch trailing newlines and encoding), or a different algorithm. Confirm all three match exactly, including whether the key is raw text or base64-decoded.

HMAC-SHA256 for anything new, widely supported and secure. HMAC-SHA512 where policy demands longer digests. HMAC-SHA1 only when a legacy API requires it.

No. The signature is computed with the Web Crypto API inside your browser; the key and message never leave your device. Closing the tab clears them from memory.

Advertisement

Sized this for your site?

Free engineers turn these numbers into a working design, topology, hardware and quote included.