Skip to content

Instantly share code, notes, and snippets.



Last active Oct 9, 2019
What would you like to do?
Generates a sha256 hash of a username:password credentials for secured basic HTTP authentication.
import sys, hashlib, base64
# USAGE: ./ "username" "password"
if len(sys.argv) != 3:
print("USAGE: username password")
def generate(username, password):
return hashlib.sha256(base64.b64encode('{0}:{1}'.format(username, password).encode())).hexdigest()
print('Your token:')
print(generate(sys.argv[1], sys.argv[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment