Last active
December 9, 2015 21:02
-
-
Save w4/e664d98c3e0d18738c33 to your computer and use it in GitHub Desktop.
Super secure random password generator. Inspired by https://xkcd.com/936/
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
from random import SystemRandom | |
from itertools import permutations | |
from math import factorial | |
from sys import argv | |
sysRandom = SystemRandom() | |
lines = open('/usr/share/dict/words').read().split('\n') | |
if len(argv) > 1 and argv[1] == 'count': | |
print("There are {0} words for us to pick from. That gives us {1} possible combinations".format(len(lines), factorial(len(lines)) / factorial(len(lines) - 4))) | |
for i in range(0, 4): | |
print((" " if i != 0 else "") + sysRandom.choice(lines), end="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment