Created
June 20, 2015 15:00
-
-
Save tianhuil/fb76402152472217f5b5 to your computer and use it in GitHub Desktop.
A script to choose high-entropy but memorial passphrases
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/python | |
""" | |
Script to generate passphrases according to the vocabular in: | |
http://world.std.com/~reinhold/diceware.wordlist.asc | |
To see why this might be a better algorithm for choosing a password: | |
https://blog.agilebits.com/2011/06/21/toward-better-master-passwords/ | |
Usage: ./dicewords.py n m | |
n - number of words per phrase | |
m - number of phrases to print | |
""" | |
import requests | |
import re | |
import sys | |
import random | |
expr = re.compile(r"^([1-6]{5})\t(.+)") | |
def get_words(): | |
text = requests.get('http://world.std.com/~reinhold/diceware.wordlist.asc').text | |
matches = [expr.match(line) for line in text.split("\n")] | |
words = [match.group(2) for match in matches if match] | |
assert(len(words) == 6 ** 5) | |
return words | |
if __name__ == "__main__": | |
if len(sys.argv) != 3: | |
print __doc__ | |
else: | |
n = int(sys.argv[1]) | |
m = int(sys.argv[2]) | |
words = get_words() | |
for _ in xrange(m): | |
print " ".join([random.choice(words) for _ in xrange(n)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment