Last active
August 1, 2019 19:45
-
-
Save poppingtonic/c7e9a91256c9c5db1676aa3c240531cf to your computer and use it in GitHub Desktop.
This script generates a list of 9 words as a "strong-enough" passphrase generator. My attempt, based on python 3.6's secrets module, to justifiably disobey the Diceware recommendation against computer-based RNGs: http://world.std.com/~reinhold/diceware.html
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/env python | |
# requires python 3.6 and requests | |
import os | |
import re | |
import secrets | |
import requests | |
wordlist_file = 'diceware.wordlist.asc' | |
if not os.path.isfile(wordlist_file): | |
print('Reticulating splines...\n') | |
data = requests.get('http://world.std.com/~reinhold/diceware.wordlist.asc').text | |
with open(wordlist_file, 'w') as f: | |
f.write(data) | |
random_integer_list = [secrets.choice(range(1, 7)) for i in range(45)] | |
f = lambda A, n=5: [A[i:i+n] for i in range(0, len(A), n)] | |
grouped_codes = f(random_integer_list) | |
passphrase_codes = map(lambda elt: r''.join(str(x) for x in elt), grouped_codes) | |
passphrase = [] | |
for code in passphrase_codes: | |
for line in open(wordlist_file, 'r'): | |
if re.match(code, line): | |
passphrase.append(line.strip().split('\t')[1]) | |
print(' '.join(passphrase)) | |
# #### download beale.wordlist.asc from http://world.std.com/~reinhold/diceware.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Relevant XKCD ᕕ( ᐛ )ᕗ