From 20b0e46a28ce08804c3ab90f624d7138e4282eeb Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 11 Jun 2012 10:36:29 +1200 Subject: [PATCH] Update develop --- plugins/password.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/plugins/password.py b/plugins/password.py index d7aaea2..537296a 100755 --- a/plugins/password.py +++ b/plugins/password.py @@ -5,42 +5,40 @@ import random def gen_password(types): - #Password Generator - The Noodle http://bowlofnoodles.net + # Password Generator - The Noodle http://bowlofnoodles.net okay = [] - #find the length needed for the password + # find the length needed for the password numb = types.split(" ") try: length = int(numb[0]) except ValueError: length = 10 - - needs_def = 0 - #alpha characters + + # add alpha characters if "alpha" in types or "letter" in types: okay = okay + string.ascii_lowercase #adds capital characters if not told not to if "no caps" not in types: okay = okay + string.ascii_uppercase - else: - needs_def = 1 - #adds numbers + + # add numbers if "numeric" in types or "numbers" in types: okay = okay + [str(x) for x in range(0, 10)] - else: - needs_def = 1 - #adds symbols + + # add symbols if "symbols" in types: sym = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', ']', '{', '}', '\\', '|', ';', ':', "'", '.', '>', ',', '<', '/', '?', '`', '~', '"'] - okay = okay + sym - else: - needs_def = 1 - #defaults to lowercase alpha password if no arguments are found - if needs_def == 1: + okay += okay + sym + + # defaults to lowercase alpha password if the okay list is empty + if not okay: okay = okay + string.ascii_lowercase + password = "" - #generates password + + # generates password for x in range(length): password = password + random.choice(okay) return password