Skip to content

Instantly share code, notes, and snippets.

@rjmoggach
Created October 11, 2014 21:44
Show Gist options
  • Save rjmoggach/25e043fd59c2d0ef54cf to your computer and use it in GitHub Desktop.
Save rjmoggach/25e043fd59c2d0ef54cf to your computer and use it in GitHub Desktop.
Random Password Generator
function random_pass {
CHARACTER_ARRAY=("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "+" "-" "." "@" "%")
RANGE=67
COUNTER=1
while [ $COUNTER -lt 16 ]; do
row[$COUNTER]=$RANDOM
let "row[$COUNTER] %= $RANGE"
while [ ${row[$COUNTER]} = 0 ]; do
row[$COUNTER]=$RANDOM
let "row[$COUNTER] %= $RANGE"
done
CHARACTER[$COUNTER]=${CHARACTER_ARRAY[${row[$COUNTER]}]}
let COUNTER=COUNTER+1
done
PASSWORD=`echo ${CHARACTER[@]:0} | sed 's/ //g'`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment