Lazo Lab Sign up

Cryptography / Hashing

Lesson 11 of 25

HMAC

An HMAC is a hash mixed with a secret key. It proves a message came from someone who knows the key and wasn't changed on the way.

Key points

  • Hash + secret key
  • Used to sign cookies and API requests
  • Flask signs its session cookie this way
import hmac, hashlib
sig = hmac.new(key, msg, hashlib.sha256).hexdigest()
Watch a video on thisOpens YouTube search results for “HMAC” in a new tab

Quiz · +10 XP

What does an HMAC add to a plain hash?

Log in to save progress and earn XP.