HMAC
PronunciationAYCH-mak
Definition
HMAC is a way to prove a message is genuine and unchanged by hashing it together with a secret key that only the sender and receiver know.
Where you hear it
In webhook verification (Stripe, GitHub), API request signing and HS256 JWTs.
Examples
Compute the HMAC of the raw body with the shared secret and compare it to the header.
Use a constant-time comparison for the signatures.
The webhook is signed with an HMAC, so we reject any request whose signature does not match.
Common mistake
Comparing signatures with ==. Timing differences can leak information; use a constant-time compare.
Don't confuse with
A plain hash, which anyone can compute. An HMAC needs the secret, so an attacker can't forge it.
Say it at work
- In a meeting or chat
Verify the HMAC before trusting the webhook.
- In an email or ticket
Rotate the signing secret.