-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_pwd.py
More file actions
47 lines (38 loc) · 1.33 KB
/
check_pwd.py
File metadata and controls
47 lines (38 loc) · 1.33 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
# Author : Clinton Lohr
# Date : 02/17/2023
# Course : CS 362 - Software Engineering II
# Assignment : TDD Hands On
# Function for checking if a password is valid
def check_pwd(input_str):
lower_check = False
upper_check = False
digit_check = False
special_check = False
special_chars = "~`!@#$%^&*()_+-="
# Checks if the length of the entered password is between 8 and 20 characters (inclusive)
if len(input_str) < 8 or len(input_str) > 20:
return False
# Checks if the input string contains at least one lowercase letter
for i in input_str:
if i.islower():
lower_check = True
break
# Checks if the input string contains at least one uppercase letter
for i in input_str:
if i.isupper():
upper_check = True
break
# Checks if the input string contains at least one digit
for i in input_str:
if i.isdigit():
digit_check = True
break
# Checks if the input string contains at least one valid special character
for i in input_str:
if i in special_chars:
special_check = True
break
# Checks if all criteria for a valid password was met
if upper_check and lower_check and digit_check and special_check:
return True
return False