Skip to content

Instantly share code, notes, and snippets.

@theY4Kman
Created October 15, 2012 16:02
Show Gist options
  • Save theY4Kman/3893296 to your computer and use it in GitHub Desktop.
Save theY4Kman/3893296 to your computer and use it in GitHub Desktop.
Python SHA-256 HMAC
from Crypto import HMAC, SHA256
def hmac_sha256(key, msg):
hash_obj = HMAC.new(key=key, msg=msg, digestmod=SHA256)
return hash_obj.hexdigest()
@psyg0501
Copy link

On Windows 7 I get this error:

from Crypto import HMAC, SHA256
Traceback (most recent call last):
File "", line 1, in
from Crypto import HMAC, SHA256
ImportError: cannot import name 'HMAC'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment