correcthorse

passphrase generator based on xkcd936
git clone git://git.pyratebeard.net/correcthorse.git
Log | Files | Refs | README

correcthorse (418B)


      1 #!/bin/sh
      2 
      3 directory=$(dirname $(readlink -f $0))
      4 word_file="${directory}/wordlist.txt"
      5 passphrase_length=5 #number of words in phrase
      6 declare -a passphrase_array
      7 
      8 for i in $(seq 1 ${passphrase_length}) ; do
      9 	wf_length=$(cat ${word_file} | wc -l)
     10 	random_num=$(shuf -i 1-${wf_length} -n 1)
     11 	random_word=$(sed "${random_num}q;d" ${word_file})
     12 	passphrase_array+=( "${random_word}" )
     13 done
     14 
     15 echo "${passphrase_array[@]}"