Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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