Skip to content

Instantly share code, notes, and snippets.

@craigderington
Created December 13, 2018 19:20
Show Gist options
  • Save craigderington/620b0fd0e97df7ebb19ad53ee62b1787 to your computer and use it in GitHub Desktop.
Save craigderington/620b0fd0e97df7ebb19ad53ee62b1787 to your computer and use it in GitHub Desktop.
Signature Verification
import hashlib
import hmac
def verify(api_key, token, timestamp, signature):
hmac_digest = hmac.new(key=mailgun_api_key,
msg='{}{}'.format(timestamp, token).encode('utf-8'),
digestmod=hashlib.sha256).hexdigest()
return hmac.compare_digest(signature, hmac_digest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment