Skip to content

Instantly share code, notes, and snippets.

@artemnikitin
Created July 7, 2014 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artemnikitin/ee3f91516fb05468d226 to your computer and use it in GitHub Desktop.
Save artemnikitin/ee3f91516fb05468d226 to your computer and use it in GitHub Desktop.
Generate Hmac SHA-1 signature via Python 2.7
#!/usr/bin/env python
import base64
import hmac
import hashlib
string = raw_input("Enter string to encode: ")
key = raw_input("Enter key: ")
hash = hmac.new(key, string, hashlib.sha1).digest()
b = base64.encodestring(hash)
b = b.rstrip()
print "Result: " + b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment