Skip to content

Instantly share code, notes, and snippets.

@mattgorecki
Created April 16, 2012 03:39
Show Gist options
  • Save mattgorecki/2396242 to your computer and use it in GitHub Desktop.
Save mattgorecki/2396242 to your computer and use it in GitHub Desktop.
Random, readable password generator for building initial passwords during signup
import string
import itertools
import random
def gen_pass():
initial_consonants = (set(string.ascii_lowercase) - set('aeiou')
# remove those easily confused with others
- set('qxc')
# add some crunchy clusters
| set(['bl', 'br', 'cl', 'cr', 'dr', 'fl',
'fr', 'gl', 'gr', 'pl', 'pr', 'sk',
'sl', 'sm', 'sn', 'sp', 'st', 'str',
'sw', 'tr'])
)
final_consonants = (set(string.ascii_lowercase) - set('aeiou')
# confusable
- set('qxcsj')
# crunchy clusters
| set(['ct', 'ft', 'mp', 'nd', 'ng', 'nk', 'nt',
'pt', 'sk', 'sp', 'ss', 'st'])
)
vowels = 'aeiou' # we'll keep this simple
# each syllable is consonant-vowel-consonant "pronounceable"
syllables = map(''.join, itertools.product(initial_consonants,
vowels,
initial_consonants,
vowels,
final_consonants))
return random.sample(syllables, 1)[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment