Skip to content

Commit 6ea9251

Browse files
authored
Add files via upload
1 parent 28577da commit 6ea9251

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import string
2+
3+
def Strength(password):
4+
5+
n = len(password)
6+
7+
hasLower = False
8+
hasUpper = False
9+
hasDigit = False
10+
specialChar = False
11+
p = string.ascii_letters + string.digits #contains all alphabets(in lower & upper case) and digits (0-9)
12+
13+
for i in range(n):
14+
if password[i].islower():
15+
hasLower = True
16+
if password[i].isupper():
17+
hasUpper = True
18+
if password[i].isdigit():
19+
hasDigit = True
20+
if password[i] not in p:
21+
specialChar = True
22+
23+
# Strength of password calculation.
24+
# password is strong only if it has both upper case and lowercase letters as well as special characters.
25+
# Also length should be greater than or equal to 8
26+
print("Strength of password:-", end = "")
27+
if (hasLower and hasUpper and
28+
hasDigit and specialChar and n >= 8):
29+
print("Strong")
30+
31+
elif ((hasLower or hasUpper) and
32+
specialChar and n >= 6):
33+
print("Moderate")
34+
else:
35+
print("Weak")
36+
37+
38+
if __name__=="__main__":
39+
40+
password = input("Enter password: ")
41+
42+
Strength(password)

0 commit comments

Comments
 (0)