diff --git a/Password-Generator/main.py b/Password-Generator/main.py index ae0d58b..fb2fde9 100644 --- a/Password-Generator/main.py +++ b/Password-Generator/main.py @@ -1,14 +1,16 @@ -""" The random module help us get random values of our choice """ +import string import random from colorama import Fore +# --- GLOBAL VARIABLES --- +letters = string.ascii_lowercase +numbers = string.digits +symbols = string.punctuation def main(): - """This is the main function and it calls all the other function - depending on user_choice""" + """This is the main function and it calls all the other function depending on user_choice""" user_choice = input( - "Type 'weak' to get a weak password, 'medium' to get a medium one \ -and 'strong' to get a strong password: " + "Type 'weak' to get a weak password, 'medium' to get a medium one \nand 'strong' to get a strong password: " ).lower() if user_choice == "weak": weak_password() @@ -19,75 +21,14 @@ def main(): else: print(Fore.RED + "Invalid Input!") - def weak_password(): - """This function will generate an weak password for you""" - letters = [ - "a", - "b", - "c", - "d", - "d", - "e", - "f", - "g", - "h", - "i", - "j", - "k", - "l", - "m", - "n", - "o", - "p", - "q", - "r", - "s", - "t", - "u", - "v", - "w", - "x", - "y", - "z", - ] + """This function will generate a weak password for you""" user_choice = int(input("How long you need your password to be: ")) password = random.choices(letters, k=user_choice) print("Here is your password: " + Fore.RED + "".join(password)) - def medium_password(): """This function will generate a medium password for you""" - letters = [ - "a", - "b", - "c", - "d", - "d", - "e", - "f", - "g", - "h", - "i", - "j", - "k", - "l", - "m", - "n", - "o", - "p", - "q", - "r", - "s", - "t", - "u", - "v", - "w", - "x", - "y", - "z", - ] - numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] letter_choice = int(input("How much letters do you want in your password: ")) number_choice = int(input("How much numbers do you want in your password: ")) letter_password = random.choices(letters, k=letter_choice) @@ -96,57 +37,8 @@ def medium_password(): random.shuffle(password) print("Here is your password: " + Fore.RED + "".join(password)) - def strong_password(): """This function will generate a strong password for you""" - letters = [ - "a", - "b", - "c", - "d", - "d", - "e", - "f", - "g", - "h", - "i", - "j", - "k", - "l", - "m", - "n", - "o", - "p", - "q", - "r", - "s", - "t", - "u", - "v", - "w", - "x", - "y", - "z", - ] - numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - symbols = [ - "~", - "@", - "#", - "$", - "%", - "^", - "&", - "*", - "(", - ")", - "?", - "/", - "<", - ">", - "|", - ] - letter_choice = int(input("How much letters do you want in your password: ")) number_choice = int(input("How much numbers do you want in your password: ")) symbol_choice = int(input("How much symbols do you want in your password: ")) @@ -157,6 +49,5 @@ def strong_password(): random.shuffle(password) print("Here is your password: " + Fore.RED + "".join(password)) - if __name__ == "__main__": - main() + main() \ No newline at end of file