Skip to content

Instantly share code, notes, and snippets.

@bmcculley
Created March 7, 2022 17:28
Show Gist options
  • Save bmcculley/bb159ec79c1edb5a14fc00163678ddaa to your computer and use it in GitHub Desktop.
Save bmcculley/bb159ec79c1edb5a14fc00163678ddaa to your computer and use it in GitHub Desktop.
Random pronounceable password generator
import random
def get_char(chars):
random_char = random.choice(chars)
if random.randrange(2):
return random_char.upper()
return random_char
def gen(length):
password = ""
consonants = "bcdfghjklmnprstvwz"
vowels = "aeiou"
all_chars = consonants + vowels
for i in range(length):
password += get_char(consonants)
password += get_char(vowels)
password += get_char(all_chars)
if i == 0:
password += str(random.randrange(99))
return password
print(gen(4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment