-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpygen.py
More file actions
215 lines (184 loc) · 7.29 KB
/
pygen.py
File metadata and controls
215 lines (184 loc) · 7.29 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/usr/bin/env python3
"""
PYGEN - Advanced Password Generator & Strength Checker
Author: Jahid Hasan
Version: 1.0
"""
import random
import math
from time import sleep
# ANSI color codes
WHITE = '\033[97m'
ORANGE = '\033[38;2;255;165;0m'
RESET = "\033[0m"
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
MAGENTA = '\033[95m'
CYAN = '\033[96m'
RESET = '\033[0m' # Reset color
def show_banner():
# ANSI color codes
ORANGE = '\033[38;2;255;165;0m'
RED = '\033[91m'
CYAN = '\033[96m'
YELLOW = '\033[93m'
RESET = '\033[0m'
banner_width = 40
# Main Banner
print(RED + r"""
██████╗ ██╗ ██╗ ██████╗ ███████╗███╗ ██╗
██╔══██╗╚██╗ ██╔╝██╔════╝ ██╔════╝████╗ ██║
██████╔╝ ╚████╔╝ ██║ ███╗█████╗ ██╔██╗ ██║
██╔═══╝ ╚██╔╝ ██║ ██║██╔══╝ ██║╚██╗██║
██║ ██║ ╚██████╔╝███████╗██║ ╚████║
╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝
""" + RESET)
print(CYAN + "=" * 70 + RESET)
# Title
print(YELLOW + " 🔑 PYGEN - Advanced Password Generator & Strength Checker" + RESET)
# Right-side small signature (banner er niche, dan pashe)
creator = "By JAHID HASAN"
print(" " * (banner_width - len(creator)) + ORANGE + creator + RESET)
print(CYAN + "=" * 70 + RESET)
def show_menu():
print(GREEN + "\nPlease Select an Option:")
print(ORANGE + "-" * 40)
print(" 1️⃣ Generate Strong Password")
print(" 2️⃣ Check Password Strength")
print(" 3️⃣ Exit Program")
print(ORANGE + "-" * 40)
def entropy(passlen):
e = passlen * math.log2(92)
print(CYAN + "Your password entropy is: ", int(e), "bit")
if e < 28:
print(GREEN + "Strength Level: 🔴 Very Weak")
elif (e > 27 and e < 36):
print(GREEN + "Strength Level: 🔴 Weak")
elif (e > 35 and e < 60):
print(GREEN + "Strength Level: 🟡 Moderate")
elif (e > 59 and e < 80):
print(GREEN + "Strength Level: 🟢 Strong")
elif (e > 79 and e < 100):
print(GREEN + "Strength Level: 🟢 Very Strong")
elif (e > 100):
print(GREEN + "Strength Level: 🔵 Extremely Strong")
try:
n = 1
while n != 0:
show_banner()
show_menu()
choice = int(input(WHITE + "Enter Your Choice: "))
sletters = list("abcdefghijklmnopqrstuvwxyz")
capletters = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
numbers = list("0123456789")
spsymbols = list("!#$%&()*+,-./:;<=>?@[]^_{|}~")
if choice == 1:
try:
n = 0
while n != 1:
print(GREEN + "\n" + "=" * 40)
print(BLUE + " 🔑 PASSWORD GENERATOR")
print(GREEN + "=" * 40)
passlen = int(input(WHITE + "How Many Password Length You Want: "))
password_list = []
password_list += list(random.choice(sletters))
password_list += list(random.choice(capletters))
password_list += list(random.choice(numbers))
password_list += list(random.choice(spsymbols))
random.shuffle(password_list)
all_chrc = sletters + capletters + numbers + spsymbols
while len(password_list) != passlen:
password_list += random.choice(all_chrc)
random.shuffle(password_list)
password = "".join(password_list)
print(CYAN + "Generating Password...")
sleep(2)
print()
print(ORANGE + "Your Password is: ", GREEN + password)
entropy(passlen)
print()
exit = input(RED + "Are You Want You Exit (y/n)? ")
if exit == "y":
n = 1
elif exit == "n":
n = 0
print()
except KeyboardInterrupt:
quit()
except EOFError:
quit()
elif choice == 3:
print(RED + "Quit....")
sleep(2)
print()
print(GREEN + "====== Thanks For Using passgen ======")
print()
break
elif choice == 2:
try:
n = 0
while n != 1:
print(GREEN + "\n" + "=" * 40)
print(BLUE + " 📊 PASSWORD STRENGTH CHECKER")
print(GREEN + "=" * 40)
print()
passwd = input(ORANGE + "Enter Your Password: ")
has_small = False
has_cap = False
has_nums = False
has_spsym = False
for c in passwd:
if c in sletters:
has_small = True
elif c in capletters:
has_cap = True
elif c in numbers:
has_nums = True
elif c in spsymbols:
has_spsym = True
r = 0
if has_small:
r += len(sletters)
if has_cap:
r += len(capletters)
if has_nums:
r += len(numbers)
if has_spsym:
r += len(spsymbols)
l = len(passwd)
e = l * math.log2(r)
print(MAGENTA + "Calculating....")
sleep(2)
print()
print(CYAN + "Your password entropy is: ", int(e), "bit")
if e < 28:
print(GREEN + "Strength Level: 🔴 Very Weak")
elif (e > 27 and e < 36):
print(GREEN + "Strength Level: 🔴 Weak")
elif (e > 35 and e < 60):
print(GREEN + "Strength Level: 🟡 Moderate")
elif (e > 59 and e < 80):
print(GREEN + "Strength Level: 🟢 Strong")
elif (e > 79 and e < 100):
print(GREEN + "Strength Level: 🟢 Very Strong")
elif (e > 100):
print(GREEN + "Strength Level: 🔵 Extremely Strong")
print()
qt = input(RED + "Are You Want You Exit (y/n)? ")
if qt == "y":
n = 1
print()
elif qt == "n":
n = 0
print()
else:
print(RED + "Wrong Input!")
except KeyboardInterrupt:
quit()
except EOFError:
quit()
except KeyboardInterrupt:
quit()
except EOFError: