Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 9 additions & 118 deletions Password-Generator/main.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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)
Expand All @@ -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: "))
Expand All @@ -157,6 +49,5 @@ def strong_password():
random.shuffle(password)
print("Here is your password: " + Fore.RED + "".join(password))


if __name__ == "__main__":
main()
main()