-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment1_Password strength_check.py
More file actions
53 lines (47 loc) · 2.17 KB
/
Copy pathAssignment1_Password strength_check.py
File metadata and controls
53 lines (47 loc) · 2.17 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
# Assignment 1 - Password strength program
def password_strength(password):
pass_val = False
while pass_val == False and password != 'q':
for y in str(password):
contains_num = y.isdigit()
if contains_num == True:
break
for y in str(password):
contains_alpha = y.isalpha()
if contains_alpha == True:
break
for y in str(password):
contains_only_alnum = y.isalnum()
if contains_only_alnum == False:
break
length = len(password)
upper_Case = password[0].isupper()
if contains_num == True:
if length >= 8:
if contains_alpha == True:
if contains_only_alnum == False:
if upper_Case == True:
print("It is a valid password")
pass_val = True
else:
print("Invalid password, first charecter shoud be upper case alphabet")
password = input("Enter a valid password, press q to quit: ")
else:
print("Invalid password, password should contain atleast one special charecter")
password = input("Enter a valid password, press q to quit: ")
else:
print("Invalid password, password doesnt contain alphabets")
password = input("Enter a valid password, press q to quit: ")
else:
print(f"Invalid password, password length is just {length}")
password = input("Enter a valid password, press q to quit: ")
else:
print("Invalid password, doesnt contain numerals")
password = input("Enter a valid password, press q to quit: ")
print("""Please setup a strong password:
Minimum length: The password should be at least 8 characters long.
Contains both uppercase and lowercase letters.
Contains at least one digit (0-9).
Contains at least one special character (e.g., !, @, #, $, %)""")
password = input("Enter the password, press q to quit: ")
password_strength(password)