Skip to content

Instantly share code, notes, and snippets.

@asottile
Created December 1, 2013 23:23
Show Gist options
  • Save asottile/7742195 to your computer and use it in GitHub Desktop.
Save asottile/7742195 to your computer and use it in GitHub Desktop.
import random
import re
simple_word_regex = re.compile('^[a-z]+$')
word_list = []
with open('/usr/share/dict/american-english', 'r') as words_file:
for word_line in words_file:
word = word_line.strip()
if simple_word_regex.match(word):
word_list.append(word)
def generate_password(length=4):
return ' '.join(
word_list[random.randint(0, len(word_list))]
for _ in xrange(length)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment