Skip to content
UPEEC

hmac

Message authentication codes — verify that data came from someone with the shared key.

Intermediate
Comments 0
import hmac, hashlib
sig = hmac.new(key, body, hashlib.sha256).hexdigest()
hmac.compare_digest(sig, received)   # constant-time comparison

This is how webhook signatures are checked.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.