What Is HMAC?
HMAC is a message authentication code computed with a shared secret and a hash function. For example, a webhook receiver can check whether a payload matches the tag created by a service that knows the secret.
How HMAC Works:
- Components:
- Message:The data you want to authenticate.
- Key:A secret key known only to the sender and the receiver.
- Hash Function:Typically, a cryptographic hash function like SHA-256 or SHA-512.
- Calculation
- Initialization:Choose an appropriate hash function (e.g., SHA-256) and a secret key K.
- Key ModificationIf necessary, modify the key to fit the hash function's block size.
- PaddingIf needed, pad the key so it fits the block size of the hash function.
When Should You NOT Use HMAC?
HMAC is not suitable for password storage or password hashing. If you are storing user passwords or deriving encryption keys from passwords, use a password hashing function instead:
- Argon2 password hash generator – Modern, memory-hard and GPU-resistant
- PBKDF2 hash generator – Widely supported key derivation function
Usage Guide - HMAC-SHA256 Online Tool
- Under Generate HMAC, enter the message and a test secret, then leave the hash function set to SHA-256.
- Choose Generate HMAC to see the Hex tag in Result. For Base64, change the selector beside Result and generate again.
- Choose Send to verification to try the generated tag. To check a tag from another source, enter the original message and shared secret, then select the matching hash function under Verify HMAC.
- Check the Received MAC (Hex or Base64) field, pasting the external tag if needed, then choose Verify HMAC.
Why does verification fail?
Try adding a space to the message and verifying the same tag again. Even one byte changes the calculation. For a webhook, use the exact text the sender authenticated, including any timestamp, line endings, or JSON whitespace covered by its signing rules.
Comparison between Hashing and Mac tools
| Algorithm | Purpose | Use for Passwords? |
|---|---|---|
| HMAC-SHA256 | Message authentication | ❌ No |
| Poly1305 | Message authentication | ❌ No |
| Argon2 | Password hashing | ✅ Yes |
| PBKDF2 | Password hashing / KDF | ✅ Yes |
If you need a modern and fast MAC algorithm, you should use: Poly1305 MAC Generator– High-performance MAC commonly used with ChaCha20.
❤️ Liked this tool?
If it saved you time, consider buying me a coffee to support future improvements.