Update develop

This commit is contained in:
Luke Rogers 2012-06-11 10:36:29 +12:00
parent f2ec2eb8d3
commit 20b0e46a28

View file

@ -5,42 +5,40 @@ import random
def gen_password(types): def gen_password(types):
#Password Generator - The Noodle http://bowlofnoodles.net # Password Generator - The Noodle http://bowlofnoodles.net
okay = [] okay = []
#find the length needed for the password # find the length needed for the password
numb = types.split(" ") numb = types.split(" ")
try: try:
length = int(numb[0]) length = int(numb[0])
except ValueError: except ValueError:
length = 10 length = 10
needs_def = 0 # add alpha characters
#alpha characters
if "alpha" in types or "letter" in types: if "alpha" in types or "letter" in types:
okay = okay + string.ascii_lowercase okay = okay + string.ascii_lowercase
#adds capital characters if not told not to #adds capital characters if not told not to
if "no caps" not in types: if "no caps" not in types:
okay = okay + string.ascii_uppercase okay = okay + string.ascii_uppercase
else:
needs_def = 1 # add numbers
#adds numbers
if "numeric" in types or "numbers" in types: if "numeric" in types or "numbers" in types:
okay = okay + [str(x) for x in range(0, 10)] okay = okay + [str(x) for x in range(0, 10)]
else:
needs_def = 1 # add symbols
#adds symbols
if "symbols" in types: if "symbols" in types:
sym = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', ']', '{', '}', '\\', '|', ';', ':', "'", '.', '>', ',', '<', '/', '?', '`', '~', '"'] sym = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', ']', '{', '}', '\\', '|', ';', ':', "'", '.', '>', ',', '<', '/', '?', '`', '~', '"']
okay = okay + sym okay += okay + sym
else:
needs_def = 1 # defaults to lowercase alpha password if the okay list is empty
#defaults to lowercase alpha password if no arguments are found if not okay:
if needs_def == 1:
okay = okay + string.ascii_lowercase okay = okay + string.ascii_lowercase
password = "" password = ""
#generates password
# generates password
for x in range(length): for x in range(length):
password = password + random.choice(okay) password = password + random.choice(okay)
return password return password