Skip to content

Instantly share code, notes, and snippets.

@notpushkin
Last active August 29, 2015 13:56
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 notpushkin/9312691 to your computer and use it in GitHub Desktop.
Save notpushkin/9312691 to your computer and use it in GitHub Desktop.
import random
def generatePassword(length):
def bigSample(orig, ln):
ls = []
while ln - len(ls) > len(orig):
ls = ls + orig
random.shuffle(ls)
return ls + random.sample(orig, ln - len(ls))
vowels = bigSample(list("aeuio"), length // 2 + 1)
consonants = bigSample(list("bcdfghjklmnpqrstvwxz") + ["th", "sh"], length // 2 + 1)
s = ""
for i in range(length // 2 + 1):
s += vowels[i] + consonants[i]
return s[:length]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment