Example
Input (message + key)
Message: GET /api/orders Key: secret-key-1234
Output (HMAC-SHA256)
3f8b2a4c1d9e7b6f5a2c8d4e1b9f6a3c7d2e8b5a4f1c9d6e3b8a5d2c9f6e3b1a
Note
HMAC is a keyed hash — requires both message and key. Without the key, you can't recreate the hash, so integrity AND authenticity are guaranteed.
Usage / FAQ
When to use
- Sign API requests — AWS Signature V4, Stripe / GitHub webhooks
- Verify that a webhook payload genuinely came from the sender
- Learn how JWT HS256 works — it's HMAC-SHA256 under the hood
- Detect tampering — without the key, an attacker can't re-sign
- Validate the integrity of security tokens (CSRF tokens, session IDs)
FAQ
- Q.HMAC vs plain hash?
- A.SHA-256(message) can be reproduced by anyone — forgeable. HMAC-SHA256(message, key) requires the key, so only key-holders can sign. Use HMAC when you need to know who sent the message.
- Q.How long should the key be?
- A.For SHA-256 based HMAC, ≥32 bytes (256 bits) is recommended. Shorter keys are auto-padded but reduce the security margin. Never hard-code keys in client code.
- Q.Do I need constant-time comparison?
- A.Yes. Plain `==` comparison on the server is vulnerable to timing attacks — attackers can guess character by character via response time. Use `crypto.timingSafeEqual` or equivalent.
Fun facts
HMAC's core insight is that naively keying a hash — `hash(key || message)` — is forgeable. SHA-1/SHA-256/MD5 all use Merkle–Damgård construction and are vulnerable to length-extension attacks. HMAC's ipad/opad double-hash cleanly blocks the whole class.
Wikipedia — Length extension attackHMAC originated in Mihir Bellare, Ran Canetti, and Hugo Krawczyk's 1996 CRYPTO paper 'Keying Hash Functions for Message Authentication,' and was standardized in 1997 as RFC 2104. IPsec, TLS, and JWT's HS256 all descend from it.
RFC 2104 (1997)HMAC verification must use a constant-time compare (`crypto.timingSafeEqual`, etc.). `===` or `strcmp` leaks a timing side-channel proportional to the matching prefix length — measurable even across the network. The 2009 Keyczar vulnerability (Lawson) is the canonical case study.
Wikipedia — Timing attack
Related tools
- Base64 Encode / Decode
Encode text to Base64 or decode Base64 back to text. Runs entirely in your browser, no data sent to any server.
- URL Encode / Decode
Percent-encode text for safe use in URLs, or decode percent-encoded URLs back to text. Runs entirely in your browser.
- UUID / ULID Generator
Generate UUID v4 (random), UUID v7 (time-ordered, RFC 9562), or ULID identifiers — all client-side via crypto.
- JWT Decoder
Decode the header and payload of a JSON Web Token. Signature is not verified (a public key is required). The token is processed entirely in your browser.
- JWT Encoder (HMAC)
Generate a signed JSON Web Token with HS256/HS384/HS512 (HMAC-SHA). Payload and secret stay in your browser — Web Crypto API based.
- SHA Hash
Compute SHA-1, SHA-256, SHA-384, or SHA-512 hash of text. Uses the browser's Web Crypto API; no data is sent to any server.
- Hex Encode / Decode
Encode text to hexadecimal or decode hex back to text. Supports UTF-8 multi-byte characters and tolerates whitespace.
- HTML Entity Encode / Decode
Encode HTML special characters (&, <, >, ", ') to entities, or decode named/numeric entities back to text.
- Password Generator
Generate cryptographically strong passwords, tokens, random strings, and passphrases with entropy display.
- Number Base Converter
Convert numbers between bases (binary/octal/decimal/hex/base36) using BigInt for large integers. Auto-detects 0b/0o/0x prefixes.
- URL Parser
Decompose a URL into protocol, host, path, query parameters, and hash — read-only inspection.
- HMAC Verify
Verify whether a given HMAC signature matches the message + secret. Constant-time comparison via Web Crypto API.
- MD5 Hash
Compute MD5 hash for text. Note: MD5 is broken for security — checksums and legacy compatibility only.
- Punycode (IDN)
Convert international domain names to/from Punycode (xn-- encoded ASCII). Uses native URL parser.
- HTTP Status Codes
Browse and search HTTP status codes (1xx-5xx) with descriptions and common usage.
- User-Agent Parser
Parse User-Agent strings into browser, OS, device, and engine fields.
- Bcrypt Hash
Hash passwords with Bcrypt or verify a plaintext against an existing hash. Configurable salt rounds.
- Cookie Parser
Parse Cookie or Set-Cookie strings into a table. Decode percent-encoded values. Supports Set-Cookie attributes (Path/Domain/Max-Age/SameSite/HttpOnly/Secure).
- IP / CIDR Calculator
Compute network address, broadcast, host range, mask, and host count from an IPv4 + CIDR.
- cURL Builder
Build cURL commands from URL/method/headers/body. Auto-detects JSON content-type.