-
Notifications
You must be signed in to change notification settings - Fork 0
/
PasswordGEN.sh
55 lines (49 loc) · 1.24 KB
/
PasswordGEN.sh
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
echo "
_____ _ _____ _____ _____
| _ |___ ___ ___ _ _ _ ___ ___ _| | __| __| | |
| __| .'|_ -|_ -| | | | . | _| . | | | __| | | |
|__| |__,|___|___|_____|___|_| |___|_____|_____|_|___|
"
echo "Enter the length of the password"
read length
string="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+"
pass=""
if ! [[ $length =~ ^[0-9]+$ ]] || [[ $length -lt 8 ]]
then
echo "Error: Enter a valid digit"
exit 1
fi
verify()
{
if [ ${#1} -lt 8 ]
then
return 0
else
if [[ $1 =~ [0-9] ]] && [[ $1 =~ [a-z] ]] && [[ $1 =~ [A-Z] ]] && [[ $1 =~ [\!\@\#\$\%\^\&\*\(\)\_\+] ]]
then
return 1
else
return 0
fi
fi
}
while [ $? -eq 0 ]
do
pass=""
for i in `seq 1 $length`
do
index=$(( RANDOM % ${#string} ))
pass=$pass${string:$index:1}
done
verify $pass
done
echo "Your password is: $pass"
if grep -qEi "(Microsoft|WSL)" /proc/version; then
echo "$pass" | clip.exe
else
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "$pass" | pbcopy
else
echo "$pass" | xclip -sel clip
fi
fi