-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpasswordStrenghtChecker.py
More file actions
56 lines (47 loc) · 2.32 KB
/
Copy pathpasswordStrenghtChecker.py
File metadata and controls
56 lines (47 loc) · 2.32 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
def evaluate_password(password):
# Boolean flag variables corresponding to each rule (criteria)
booleanFlag1 = False # Rule 1: Contains uppercase and lowercase letter
booleanFlag2 = False # Rule 2: At least one number and one symbol
booleanFlag3 = False # Rule 3: Can't enter patterns like "123, abc"
booleanFlag4 = False # Rule 4: Must be more than 8 characters
# Criteria checks
'''
# ToDo:
# Code for at least three rule (criteria) evaluate a given password for its security strength.
# For each criteria, check the desired condition and save the status in the corresponding boolean flag variable.
# You can use Python's built-in functions and modules for help.
'''
# YOUR CODE GOES HERE
# Rule 1: Check for at least one uppercase and one lowercase letter
if any(c.islower() for c in password) and any(c.isupper() for c in password):
booleanFlag1 = True
# Rule 2: Check for at least one number and one symbol
if any(c.isdigit() for c in password) and any(c in '!@#$%^&*()_+-=[]{}|;:,.<>?/~`' for c in password):
booleanFlag2 = True
# Rule 3: Check for patterns like "123" or "abc"
patterns = ["123", "abc"]
if not any(pattern in password.lower() for pattern in patterns):
booleanFlag3 = True
# Rule 4: Check if the password is more than 8 characters
if len(password) > 8:
booleanFlag4 = True
# Evaluate the final result using logical AND between flags
if booleanFlag1 and booleanFlag2 and booleanFlag3 and booleanFlag4:
return "Compliant"
else:
non_compliant_message = "Non-compliant.\n The given password did not pass the following criteria:"
if not booleanFlag1:
non_compliant_message += "\n - Must contain both uppercase and lowercase letters."
if not booleanFlag2:
non_compliant_message += "\n - Must contain at least one number and one symbol."
if not booleanFlag3:
non_compliant_message += "\n - Can't contain patterns like '123' or 'abc'."
if not booleanFlag4:
non_compliant_message += "\n - Must be more than 8 characters." # Added rule (Not in rules.txt)
return non_compliant_message
'''
# Do not change the code below
'''
# User input
password = input("Enter your password: ")
print(evaluate_password(password))