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.

Revisions

  1. @invalid-email-address Anonymous created this gist Apr 16, 2012.
    33 changes: 33 additions & 0 deletions gen_pass.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    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]