Skip to content
secureHMAC · 256 bits · 1996

HMAC-SHA256

The right way to authenticate a message with a shared secret. AWS V4 signatures, Stripe webhooks, JWT HS256: all HMAC-SHA256 underneath.

By ·

HMAC (Hash-based Message Authentication Code) is the canonical way to combine a secret key and an arbitrary message into an authentication tag. The construction is intentionally simple: `HMAC(k, m) = H((k ⊕ opad) || H((k ⊕ ipad) || m))`. The double-hash with two padded keys neutralizes length-extension attacks on the underlying hash, which is why you never want to roll your own `H(key || message)`: that pattern *is* exploitable on SHA-2. HMAC-SHA256 is the default for new API signing schemes (AWS V4, Stripe webhooks, GitHub webhooks, JWT HS256). If you're picking between HMAC-SHA256 and Poly1305 / GMAC / BLAKE3-keyed, HMAC-SHA256 is the safest interoperable choice; the others are faster but harder to glue into existing ecosystems.

Recommended uses

  • ·API request signing (AWS-V4-style)
  • ·Webhook payload verification
  • ·JWT HS256 / HS512 signing
  • ·Anywhere you need MAC semantics over an existing hash

Known attacks / caveats

  • ·None practical against HMAC-SHA256.

Designed by

Bellare, Canetti, Krawczyk, published 1996.

Try it in the HMAC demo →

Frequently asked questions

Is HMAC-SHA256 secure in 2026?
Yes. HMAC-SHA256 has no practical breaks as of 2026. Caveats worth knowing: None practical against HMAC-SHA256.
What is HMAC-SHA256 used for?
API request signing (AWS-V4-style). Webhook payload verification. JWT HS256 / HS512 signing. Anywhere you need MAC semantics over an existing hash.
How long is the output of HMAC-SHA256?
256 bits, which is 32 bytes, or 64 characters when written as hexadecimal. The length is fixed regardless of how large the input is.
Can HMAC-SHA256 be used to hash passwords?
No, and this is the most consequential mistake people make with it. HMAC-SHA256 is a fast general-purpose hash, and fast is exactly the wrong property for passwords: it lets an attacker with a stolen database test billions of guesses. Use a purpose-built password hashing function such as Argon2id instead.
Who created HMAC-SHA256?
Bellare, Canetti, Krawczyk, published in 1996.

Further reading