-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_strength.sh
More file actions
32 lines (26 loc) · 813 Bytes
/
password_strength.sh
File metadata and controls
32 lines (26 loc) · 813 Bytes
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
#!/bin/bash
# Prompt the user to enter a password
read -sp "Enter your password: " password
echo
# Check for minimum length of 8 characters
if [[ ${#password} -lt 8 ]]; then
echo "<Weak Password>: Password must be at least 8 characters long."
exit 1
fi
# Check for at least one lowercase letter
if ! [[ $password =~ [a-z] ]]; then
echo "<Weak Password>: Password must contain at least one lowercase letter."
exit 1
fi
# Check for at least one uppercase letter
if ! [[ $password =~ [A-Z] ]]; then
echo "<Weak Password>: Password must contain at least one uppercase letter."
exit 1
fi
# Check for at least one digit
if ! [[ $password =~ [0-9] ]]; then
echo "<Weak Password>: Password must contain at least one number."
exit 1
fi
# If all checks pass
echo "Password is strong."