Created
January 4, 2012 08:22
-
-
Save kotas/1559083 to your computer and use it in GitHub Desktop.
Password Generator for Mac OSX
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 | |
# -*- encoding: utf-8 -*- | |
""" | |
Password Generator for Mac OSX | |
Compatible with http://www.hashapass.com/ | |
""" | |
import sys | |
import os | |
import hmac | |
import hashlib | |
import base64 | |
os.system("stty -echo >/dev/null 2>&1") | |
try: | |
sys.stdout.write("Type master: ") | |
master = sys.stdin.readline().rstrip() | |
sys.stdout.write("\r" + " " * 80 + "\r") | |
sys.stdout.write("Type parameter: ") | |
parameter = sys.stdin.readline().rstrip() | |
sys.stdout.write("\r" + " " * 80 + "\r") | |
gen = hmac.new(master, parameter, hashlib.sha1) | |
password = base64.b64encode(gen.digest()) | |
password = password[0:8] | |
clipboard = os.popen("pbcopy", "w") | |
clipboard.write(password) | |
clipboard.close() | |
sys.stdout.write("Password is set to clipboard.\n") | |
finally: | |
os.system("stty echo >/dev/null 2>&1") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment