Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # coding=utf-8
- """Produces a unique, secure password from a site name and a secure Master Passphrase."""
- import hashlib
- # for python3 change raw_input to input
- print("""Enter the Site Name. If using the entire address, be aware that sites are
- increasingly moving from http to https, which would alter the result.""")
- site_name = raw_input('>> ')
- print("""Enter your Master Passphrase. This needs to be very secure, in cases someone
- knows/guesses you're using this. Diceware is recommended:
- http://world.std.com/~reinhold/diceware.html""")
- sekrit = raw_input('>> ')
- combined_string = "%s~%s" % (site_name, sekrit)
- md = hashlib.md5()
- md.update(combined_string)
- hex_string = md.hexdigest()
- print("MD5 hash:\n%s" % hex_string)
- # This grabs the last 16 (of 32) digits. Change the slice to grab different ones.
- short_string = hex_string[-16:]
- print("16 digit:\n%s" % short_string)
- # This part both obsfucates that we're using hexidecimal numbers, and (nearly always) adds
- # in some special characters for finicky sites
- # change/rearrange the 'Y' part of each 'x':'Y' pair to mix things up (keep the quotes!)
- # Note every nth number is changed to a special character, and every nth letter is uppercased
- # or changed to a value outside the hexadecimal range (>a-f)
- special_dict = {'0':'ยข','1':'~','2':'!','3':'@','4':'#','5':'$','6':'%','7':'^','8':'&','9':'*'}
- alpha_dict ={'a':'G','b':'L','c':'m','d':'t','e':'V','f':'x'}
- pwd_list = []
- # Making this number too high reduces the chances of a special character (which some sites require)
- nth = 3
- use_dict = True
- for x in range(len(short_string)):
- i = short_string[x]
- if ((x+1) % nth != 0):
- pwd_list.append(i)
- elif i.isdigit():
- pwd_list.append(special_dict[i])
- else:
- if use_dict:
- pwd_list.append(alpha_dict[i])
- else:
- pwd_list.append(i.upper())
- use_dict = not use_dict
- pwd_string = ''.join(pwd_list)
- # We should end up with a decent password that's reproducible, unique, and secure
- print("Obsfucated 16 digit:\n%s" % pwd_string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement