-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsgp.sh
117 lines (102 loc) · 2.27 KB
/
sgp.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Perbaikan Panjang Password tidak bisa lebih dari 50
# Makasih sudah baca notice ini :)
r='\033[0;31m' # red
g='\033[0;32m' # green
n='\033[0m' # no color
show_usage() {
echo "usage: $0 [ options ]"
echo "-h, --help [ show help message ]"
echo "-i, --information [ show information tools ]"
}
show_help() {
clear
echo "usage: $0 [ options ]"
echo "-p [ password length max 50 ]"
echo "-u [ use uppercase ]"
echo "-l [ use lowercase ]"
echo "-n [ use numbers ]"
echo "-s [ use symbols ]"
echo "-ac [ use all characters ]"
echo "bash sgp.sh -p 10 -u use -l use -s use -n use"
}
show_information() {
clear
cowsay SGP
echo "name: Secure Generator Password (sgp)"
echo "version: 1.0.0"
echo "author: msverse.site"
echo "homepage: https://www.msverse.site"
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-p)
LENGTH="$2"
if [[ $LENGTH -gt 50 ]]; then
LENGTH=50
fi
shift
shift
;;
-u)
USE_UPPERCASE="use"
shift
;;
-l)
USE_LOWERCASE="use"
shift
;;
-n)
USE_NUMBERS="use"
shift
;;
-s)
USE_SYMBOLS="use"
shift
;;
-ac)
USE_ALLCHARS="use"
shift
;;
-h|--help)
show_help
exit 0
;;
-i|--information)
show_information
exit 0
;;
*)
shift
;;
esac
done
if [[ -z $LENGTH ]]; then
LENGTH=16
fi
CHARACTERS=""
if [[ $USE_UPPERCASE == "use" ]]; then
CHARACTERS+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
fi
if [[ $USE_LOWERCASE == "use" ]]; then
CHARACTERS+="abcdefghijklmnopqrstuvwxyz"
fi
if [[ $USE_NUMBERS == "use" ]]; then
CHARACTERS+="0123456789"
fi
if [[ $USE_SYMBOLS == "use" ]]; then
CHARACTERS+="!@#$%^&*()-=_+[]{}|;:,.<>?/~"
fi
if [[ $USE_ALLCHARS == "use" ]]; then
CHARACTERS+="!@#$%^&*()-=_+[]{}|;:,.<>?/~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
fi
if [[ -z $CHARACTERS ]]; then
cowsay SGP
show_usage
exit 1
fi
for i in {1..5}; do
PASSWORD=$(tr -dc "$CHARACTERS" < /dev/urandom | head -c "$LENGTH")
echo -e "${r}[${g} $PASSWORD ${r}]${n}"
done