Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ma7555/0c6d5b11321283dc6ae03c4245082c08 to your computer and use it in GitHub Desktop.
Save ma7555/0c6d5b11321283dc6ae03c4245082c08 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