Created
December 30, 2016 14:51
-
-
Save rjzak/1619a7def053515f847ec98381fadaed to your computer and use it in GitHub Desktop.
Revisions
-
rjzak created this gist
Dec 30, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #!/usr/bin/python3 import os import sys import glob import codecs import random cleanup = lambda x: x.split("/")[0] if "/" in x else x # Some hunspell entries have slashes in the second to last character. num = 4 if len(sys.argv) > 1: try: num = int(sys.argv[1]) except: pass words = list() dicts = list() if os.path.exists("/usr/share/hunspell"): dicts += glob.glob("/usr/share/hunspell/*.dic") if os.path.exists("/usr/share/dict"): dicts += glob.glob("/usr/share/dict/*-*") for dictfile in dicts: with open(dictfile, encoding="utf-8", errors="ignore") as f: [words.append(cleanup(word.strip())) for word in f] words = list(set(words)) password = ' '.join(random.choice(words) for i in range(num)) print(password) print("Generated from %d dictionary files." % len(dicts))