Created
April 3, 2017 22:23
-
-
Save dwinston/d7e696406c0aed59fcf56f6ef9f85c6d to your computer and use it in GitHub Desktop.
Generate a password/passphrase that is just many words strung together
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
"""Generate n-word (default n=5) passwords separated by sep (default '-'). | |
Uses your friendly neighborhood words file by default. | |
Simple Use: `python nwordspass.py` | |
Help: `python nwordspass.py --help` | |
""" | |
import argparse | |
import random | |
parser = argparse.ArgumentParser( | |
description='Generate n-word passwords separated by sep.') | |
parser.add_argument('-n', type=int, default=5, | |
help='Number of words (default 5)') | |
parser.add_argument('-s', '--sep', type=str, default='-', | |
help='Separator for words (default "-")') | |
parser.add_argument( | |
'--wf', type=str, | |
default='/usr/share/dict/words', | |
help='Path to words file (default "/usr/share/dict/words")') | |
args = parser.parse_args() | |
n, sep, wf = args.n, args.sep, args.wf | |
with open(wf) as f: | |
lines = f.readlines() | |
words = set(line.strip().lower() for line in lines) | |
result = sep.join(random.sample(words, n)) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment