forked from I-RoshanKumar/Beginner_Hactoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Password_categorizer.py
35 lines (26 loc) · 944 Bytes
/
Password_categorizer.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
import re
def password(v):
if v == "\n" or v == " ":
return "Password cannot be a newline or space!"
if 9 <= len(v) <= 20:
# checks for occurrence of a character
# three or more times in a row
if re.search(r'(.)\1\1', v):
return "Weak Password: Same character repeats three or more times in a row"
# checks for occurrence of same string
# pattern( minimum of two character length)
# repeating
if re.search(r'(..)(.*?)\1', v):
return "Weak password: Same string pattern repetition"
else:
return "Strong Password!"
else:
return "Password length must be 9-20 characters!"
def main():
# Driver code
print(password("password"))
print(password("6gh&^%TRy765RTy74"))
print(password("*&^RFghuiyU*&^Ty"))
print(password(" "))
if __name__ == '__main__':
main()