File tree 1 file changed +8
-8
lines changed
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 4
4
# #### Functions #####
5
5
function generate_password() {
6
6
# SC => special characters allowed
7
- SC=" _- "
7
+ SC=" _"
8
8
while
9
- _password=$( cat /dev/urandom | tr -dc ' a-zA-Z0-9 ' $SC | head -c $ (($RANDOM % 6 + 15 )) )
10
- [[
11
- $( echo $_password | grep -o ' [' $SC ' ]' | wc -l) < 2
12
- || $( echo $_password | grep -o ' [0-9]' | wc -l) < 2
13
- || $( echo $_password | grep -o ' [A-Z]' | wc -l) < 2
14
- || $( echo $_password | grep -o ' [a-z]' | wc -l) < 2
9
+ _password=$( openssl rand -base64 $ (($RANDOM % 6 + 15 )) | tr ' [:punct:] ' $SC )
10
+ [[
11
+ $( echo $_password | grep -o ' [' $SC ' ]' | wc -l) -lt 2
12
+ || $( echo $_password | grep -o ' [0-9]' | wc -l) -lt 2
13
+ || $( echo $_password | grep -o ' [A-Z]' | wc -l) -lt 2
14
+ || $( echo $_password | grep -o ' [a-z]' | wc -l) -lt 2
15
15
]]
16
16
do true ; done
17
-
17
+
18
18
echo $_password
19
19
}
20
20
You can’t perform that action at this time.
0 commit comments