Created
December 8, 2014 13:24
-
-
Save esiqveland/3e44035313ecfaf5b305 to your computer and use it in GitHub Desktop.
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
import hashlib | |
import sys | |
import base64 | |
def compute(password): | |
m = hashlib.sha1() | |
m.update(password) | |
digest = m.digest() | |
b64 = base64.b64encode(digest) | |
return b64 | |
def output(username, encryptedPassword): | |
return "{0}:{1}".format(username,encryptedPassword) | |
def usage(): | |
print "{0}: `username` `password`".format(sys.argv[0]) | |
def main(): | |
if len(sys.argv) < 3: | |
usage() | |
sys.exit(1) | |
username = sys.argv[1] | |
password = sys.argv[2] | |
encryptedPassword = compute(password) | |
print output(username, encryptedPassword) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment