File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 44# #### Functions #####
55function generate_password() {
66 # SC => special characters allowed
7- SC=" _- "
7+ SC=" _"
88 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
1515 ]]
1616 do true ; done
17-
17+
1818 echo $_password
1919}
2020
You can’t perform that action at this time.
0 commit comments