Skip to content

Instantly share code, notes, and snippets.

@ryanbarrett
Created January 11, 2017 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbarrett/2680cb170b9de1458dcd56c3b78d3c42 to your computer and use it in GitHub Desktop.
Save ryanbarrett/2680cb170b9de1458dcd56c3b78d3c42 to your computer and use it in GitHub Desktop.
Generate Passwords from the list of EFF dice passwords
import sys
import argparse
import random
import re
argparser = argparse.ArgumentParser(
description='Arguments that may be parsed.', epilog="Use good passwords")
argparser.add_argument('--words', default=5, type=int,
help='Number of words to return. e.g. --words 5 (default)')
argparser.add_argument('--filename', default='eff_large_wordlist.txt', type=str,
help='https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt dicelist filename must be lines of six digits and a word e.g. "######<space or tab>word" Default: eff_large_wordlist.txt')
args = argparser.parse_args()
def ReadWordsFromFile(filename):
words = {}
try:
with open(filename, 'r') as thefile:
for word in thefile.readlines():
w = re.split(r'\s+', word.rstrip('\n'))
words[w[0]] = w[1]
except Exception as e:
raise
return words
def ReturnRandomInts(howmanywords):
listofrandomints = []
for i in range(0, howmanywords):
stringofints = ""
for r in range(0, 5):
stringofints += str(random.randint(1, 6))
listofrandomints.append(str(stringofints))
return listofrandomints
def main(args):
howmanywords = args.words
words = ReadWordsFromFile(args.filename)
yourwords = []
listofrandomints = ReturnRandomInts(howmanywords)
for randomint in listofrandomints:
yourwords.append(words[randomint])
print(words[randomint])
agoodpassword = ""
for word in yourwords:
agoodpassword += word + " "
print("A Good Password: " + agoodpassword)
print("A really Good Password: " +
agoodpassword + str(random.randint(0, 999)))
# print(re.sub('["\'\[\]]','',str(yourwords)))
if __name__ == "__main__":
try:
main(args)
except(Exception):
raise
else:
pass
finally:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment