Skip to content

Instantly share code, notes, and snippets.

@BOPOHOB
Forked from heskyji/hmac_sha1.py
Last active March 30, 2018 14:21
Show Gist options
  • Save BOPOHOB/fc83268cba799d7b830f959f0a23b135 to your computer and use it in GitHub Desktop.
Save BOPOHOB/fc83268cba799d7b830f959f0a23b135 to your computer and use it in GitHub Desktop.
Generate HMAC-SHA1 Signature using Python 3
import hashlib
import hmac
import base64
import click
def make_digest(message):
key = bytes(message, 'UTF-8')
message = bytes(message, 'UTF-8')
digester = hmac.new(key, message, hashlib.sha1)
signature1 = digester.digest()
signature2 = base64.urlsafe_b64encode(signature1)
return str(signature2, 'UTF-8')
@click.command()
@click.argument('for_encript')
def encode(for_encript):
print(make_digest(for_encript))
if __name__ == "__main__":
encode()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment