Skip to content

Instantly share code, notes, and snippets.

@gauravvjn
Last active February 7, 2022 23:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • 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