Skip to content

Instantly share code, notes, and snippets.

@bhuvidya
Created March 9, 2016 08:00
Show Gist options
  • Save bhuvidya/f4f82f52fa4ecc8fe995 to your computer and use it in GitHub Desktop.
Save bhuvidya/f4f82f52fa4ecc8fe995 to your computer and use it in GitHub Desktop.
dice ware word generator
#!/bin/bash
# see https://blog.agilebits.com/2011/06/21/toward-better-master-passwords/
# and http://world.std.com/~reinhold/diceware.wordlist.asc
DICEWARE_STASH_FILE=~/tmp/diceware.txt
WORDS=$1
[[ "$WORDS" == "" ]] && WORDS=5
# make sure the directory of the stash file exists...
DIR=$(dirname "$DICEWARE_STASH_FILE")
#[ !
# stash the current list of diceware words
[ ! -d ~/tmp ] && mkdir ~/tmp
if [ ! -f $DICEWARE_STASH_FILE ]; then
curl -s http://world.std.com/~reinhold/diceware.wordlist.asc | grep -E "^[1-6]{5}" > $DICEWARE_STASH_FILE
fi
# create some random sequences of "dice throws"
export LC_CTYPE=C
for i in {1..10}; do
cat /dev/urandom | tr -dc '1-6' | fold -w 5 | /usr/bin/head -n $WORDS | while read throw; do
grep -E "^$throw" $DICEWARE_STASH_FILE | awk '{ printf "%s ", $2 }'
done
echo
done
@bhuvidya
Copy link
Author

bhuvidya commented Mar 9, 2016

  1. download to your home dir
  2. open up terminal
  3. chmod +x diceware_passwd.sh
  4. ./diceware_passwd.sh

this will download the diceware word list if it hasn't been already, then generate lists of 5 random words from the big list. you can pass a number as a parameter to the script to generate that many words in each string.

why is diceware good for generating strong yet memorable passwords? see:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment