generated from Code-Institute-Org/p3-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpassword_checker_zxcvbn.py
50 lines (46 loc) · 1.87 KB
/
password_checker_zxcvbn.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
"""Used in option 1 and option 4 for password strength checking"""
from packages_global_vars import *
def password_checker(input_string):
"""Takes in a password (string), and returns
a print statement on the time taken to crack password"""
init(autoreset=True)
if input_string == "" or len(input_string) == 0:
print("Please enter a valid password")
new_input = getpass("Enter the password to check: ")
password_checker(new_input)
elif input_string == "q":
print("Exiting...")
return
else:
# second includes "seconds" day includes "days" week includes "weeks"
reset_colours = Style.RESET_ALL
results = zxcvbn(input_string)
results_in_time = results.get("crack_times_display").get(
"online_throttling_100_per_hour")
if ("second" in results_in_time
or "minute" in results_in_time
or "hour" in results_in_time
or "day" in results_in_time
or "week" in results_in_time):
fore_ground = Fore.WHITE
back_ground = Back.RED
# month includes "months year includes "years"
elif "month" in results_in_time:
fore_ground = Fore.YELLOW
back_ground = Back.BLACK
elif "year" in results_in_time:
fore_ground = Fore.GREEN
back_ground = Back.WHITE
else:
fore_ground = Fore.GREEN
back_ground = Back.WHITE
print(f"At a rate of 100 guesses per hour your password would \
take {fore_ground}{back_ground}{results_in_time}{reset_colours} to crack")
# removing password from memory
del results
del results_in_time
print("")
print("Deleting Password..")
print("Your password has been deleted from memory..")
input("Press enter to continue")
os.system('cls||clear')