Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save indraone01/643ff6dc9ade026fc816bf2180303691 to your computer and use it in GitHub Desktop.
Save indraone01/643ff6dc9ade026fc816bf2180303691 to your computer and use it in GitHub Desktop.
Create HMAC SHA256 signature/encryption/encode
"""
https://gist.github.com/Azadehkhojandi/50eaae4cf20b21faef186f2c8ee97873
"""
import hmac
import hashlib
import binascii
def create_sha256_signature(key, message):
"""
"""
byte_key = binascii.unhexlify(key)
message = message.encode()
return hmac.new(byte_key, message, hashlib.sha256).hexdigest().upper()
key = "E49756B4C8FAB4E48222A3E7F3B97CC3"
message = "TEST STRING"
create_sha256_signature(key, message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment