- What's HMAC for?
- Verifying that a message hasn't been tampered with. Combines a secret key with a hash (SHA-256, SHA-512) to produce a signature. Used in webhooks, API signatures, JWT.
- Which hash should I use?
- SHA-256 is the modern default. SHA-1 is deprecated but still common in legacy systems. SHA-512 is slightly stronger but rarely necessary.
- How do I verify?
- Compute HMAC on your side with the same key; compare with the received signature using a constant-time comparison (to prevent timing attacks).
- Can it encrypt?
- No — HMAC is for authentication, not encryption. Pair with AES for authenticated encryption (or use AES-GCM which does both).