-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassword Complexity Checker
More file actions
55 lines (46 loc) · 1.57 KB
/
Password Complexity Checker
File metadata and controls
55 lines (46 loc) · 1.57 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
import re
#Input the password from the user
password=input("Enter a password to check the strength:")
#Initialize the strength of the password
total=0
feedback=[]
#Checking the length of the password
if len(password)<6:
feedback.append("Password is too short. Minimum length of the password is 6 characters.")
elif len(password)>=9:
total+=1
else:
feedback.append("Password length is acceptable but less than suggested 9 characters.")
#Checking for lowercase alphabets
if re.search(r'[a-z]',password):
total+=1
else:
feedback.append("Password must contain atleast one lowercase alphabet.")
#Checking for uppercase alphabets
if re.search(r'[A-Z]',password):
total+=1
else:
feedback.append("Password must contain atleast one uppercase alphabet.")
#Checking for numbers:
if re.search(r'\d',password):
total+=1
else:
feedback.append("Password must contain one numerical value.")
#Checking for special numbers:
if re.search(r'[!@#$%^&*(),.?":{}|<>]',password):
total+=1
else:
feedback.append("Password must contain atleast one special character.")
#Assessing the strength of the password
if total==5:
strength="Password is very strong."
elif total>=3:
strength="Password is strong."
elif total==2:
strength="Password is medium."
else:
strength="Password is weak."
#Printing the output
print(f"password strength: {strength}")
for comment in feedback:
print(f"- {comment}")