Skip to content

Instantly share code, notes, and snippets.

@iamd3vil
Last active February 23, 2016 18:20
Show Gist options
  • Save iamd3vil/7c05770cebd066a975d5 to your computer and use it in GitHub Desktop.
Save iamd3vil/7c05770cebd066a975d5 to your computer and use it in GitHub Desktop.
hmac_python.py
import hashlib
import hmac
secret_key = b"secret-key"
text = b"This is a secret"
hmac_sha1 = hmac.HMAC(key=secret_key, msg=text, digestmod=hashlib.sha1).hexdigest()
print("HMAC is {}".format(hmac_sha1)) # HMAC is 08dc7014b3e778a44af52ea7a16a973a9b48f0dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment