-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain.py
166 lines (155 loc) · 3.61 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
""" The random module help us get random values of our choice """
import random
from colorama import Fore
def main():
"""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: "
).lower()
if user_choice == "weak":
weak_password()
elif user_choice == "medium":
medium_password()
elif user_choice == "strong":
strong_password()
else:
print(Fore.RED + "Invalid Input!")
def weak_password():
"""This function will generate an weak password for you"""
letters= [chr(i) for i in range(ord('a'), ord('z') + 1)]
print(letters)
"""
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",
]
"""
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)
number_password = random.choices(numbers, k=number_choice)
password = letter_password + number_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: "))
letter_password = random.choices(letters, k=letter_choice)
number_password = random.choices(numbers, k=number_choice)
symbol_password = random.choices(symbols, k=symbol_choice)
password = letter_password + number_password + symbol_password
random.shuffle(password)
print("Here is your password: " + Fore.RED + "".join(password))
if __name__ == "__main__":
main()