<reponame>davidp799/passowrd-generator<gh_stars>0
"""
Author: <NAME>

Module for python based password generator
"""
import random, string, array

def password_generator(length=16, symbols=True, numbers=True, lowers=True, uppers=True, ambiguous=True):
    if length < 6:
        raise Exception("Error: Password must be 6 or more characters in length!")
    elif length > 128:
        raise Exception("Error: Password may not exceed 128 characters in length!")
    elif symbols==False and numbers==False and lowers==False and uppers==False and ambiguous==False:
        raise Exception("Error: Password must include at least 1 character type!")

    status_list = [symbols, numbers, lowers, uppers, ambiguous]
    
    sym_lst= list("!@#$%^&*_-+=|?")
    num_lst = list("0123456789")
    lwr_lst, upr_lst = list(string.ascii_lowercase), list(string.ascii_uppercase)
    amb_lst = list("{}[]()/\'`~,;:.<>") + list('"')
    
    rand_num, rand_lwr, rand_upr = random.choice(num_lst), random.choice(lwr_lst), random.choice(upr_lst)
    rand_sym, rand_amb = random.choice(sym_lst), random.choice(amb_lst)

    data_types = [sym_lst, num_lst, lwr_lst, upr_lst, amb_lst]
    rand_data = [rand_sym, rand_num, rand_lwr, rand_upr, rand_amb]
    allChars, temp_pass, indx = [], "", 0

    for obj in status_list:
        if obj == True:
            temp_pass += rand_data[indx]
            allChars += data_types[indx]
        indx += 1

    for i in range(length - len(temp_pass)):
            temp_pass = temp_pass + random.choice(allChars)
            temp_pass_list = array.array('u', temp_pass)
            random.shuffle(temp_pass_list)

    password = ""
    for char in temp_pass_list:
        password = password + char

    return password

    

"""
Author: <NAME>

Module for python based password generator
"""
import random, string, array

def password_generator(length=16, symbols=True, numbers=True, lowers=True, uppers=True, ambiguous=True):
    if length < 6:
        raise Exception("Error: Password must be 6 or more characters in length!")
    elif length > 128:
        raise Exception("Error: Password may not exceed 128 characters in length!")
    elif symbols==False and numbers==False and lowers==False and uppers==False and ambiguous==False:
        raise Exception("Error: Password must include at least 1 character type!")

    status_list = [symbols, numbers, lowers, uppers, ambiguous]
    
    sym_lst= list("!@#$%^&*_-+=|?")
    num_lst = list("0123456789")
    lwr_lst, upr_lst = list(string.ascii_lowercase), list(string.ascii_uppercase)
    amb_lst = list("{}[]()/\'`~,;:.<>") + list('"')
    
    rand_num, rand_lwr, rand_upr = random.choice(num_lst), random.choice(lwr_lst), random.choice(upr_lst)
    rand_sym, rand_amb = random.choice(sym_lst), random.choice(amb_lst)

    data_types = [sym_lst, num_lst, lwr_lst, upr_lst, amb_lst]
    rand_data = [rand_sym, rand_num, rand_lwr, rand_upr, rand_amb]
    allChars, temp_pass, indx = [], "", 0

    for obj in status_list:
        if obj == True:
            temp_pass += rand_data[indx]
            allChars += data_types[indx]
        indx += 1

    for i in range(length - len(temp_pass)):
            temp_pass = temp_pass + random.choice(allChars)
            temp_pass_list = array.array('u', temp_pass)
            random.shuffle(temp_pass_list)

    password = ""
    for char in temp_pass_list:
        password = password + char

    return password
Author: <NAME>  Module for python based password generator #$%^&*_-+=|?")