What is an HMAC?
An HMAC (hash-based message authentication code) is a hash that also depends on a secret key. Only someone who knows the key can produce the right value for a message. It proves two things: the message came from a holder of the key, and it was not changed on the way.
It is not simply the hash of the key and message joined together. HMAC mixes the key into the hash in two rounds, which avoids weaknesses of the simple approach. APIs and webhooks use it to sign requests, and JWTs with HS256 use it for their signature. Keep the key secret.
HMAC(K, m) = H((K′ ⊕ opad) ‖ H((K′ ⊕ ipad) ‖ m))
How to use the HMAC Generator
- Enter the message.
- Enter the secret key, and say whether it is text or hex.
- Choose the hash algorithm.
- Pick hex or Base64 and copy the HMAC.