Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@w4
Last active December 9, 2015 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save w4/e664d98c3e0d18738c33 to your computer and use it in GitHub Desktop.
Save w4/e664d98c3e0d18738c33 to your computer and use it in GitHub Desktop.
Super secure random password generator. Inspired by https://xkcd.com/936/
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