Skip to content

Instantly share code, notes, and snippets.

@gauravvjn
Last active February 7, 2022 23:58
Show Gist options
  • Save gauravvjn/172a4a9933626bd507e00ae6245e33a1 to your computer and use it in GitHub Desktop.
Save gauravvjn/172a4a9933626bd507e00ae6245e33a1 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