Skip to content

Instantly share code, notes, and snippets.

@mike-spainhower
Last active January 13, 2020 21:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-spainhower/6911621 to your computer and use it in GitHub Desktop.
Save mike-spainhower/6911621 to your computer and use it in GitHub Desktop.
Bourne Shell script that outputs xkcd password generator passwords using secure random. http://xkcd.com/936/
#!/bin/sh
rand_num=""
tot_words="`wc -l /usr/share/dict/words | cut -f1 -d' '`"
refresh_random () {
rand_num=`od -An -N4 -tu4 /dev/random`
}
for i in `seq 1 4` ; do
refresh_random
printf `tail -$((rand_num % tot_words)) /usr/share/dict/words | head -1 | sed "s;';;g"`
if [ $i != 4 ] ; then printf _ ; fi
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment