Last active
October 9, 2019 12:05
-
-
Save cnicodeme/32bfcda65e642204cf2f5f87d94fa612 to your computer and use it in GitHub Desktop.
Generates a sha256 hash of a username:password credentials for secured basic HTTP authentication.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys, hashlib, base64 | |
# USAGE: ./token.py "username" "password" | |
if len(sys.argv) != 3: | |
print("USAGE: script.py username password") | |
exit(1) | |
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