Skip to content

Instantly share code, notes, and snippets.

@iqbalhasnan
Created January 23, 2014 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iqbalhasnan/8584506 to your computer and use it in GitHub Desktop.
Save iqbalhasnan/8584506 to your computer and use it in GitHub Desktop.
generate random password with diceware wordlist
#!/bin/bash
#
# Author: Iqbal Hasnan and Tony Xu at The Ohio State University
# Description: This script generates a secure, easy-to-remembers random passphrase
# based on diceware wordlist and random number from random.org
#
# run: ./passwordgenerator.sh
# check if the diceware wordlist exists in local machine
if [ ! -f diceware.txt ]; then
curl -L http://goo.gl/djmh54 > diceware.txt
fi
# get 5 5-digit random numbers generated from random.org with the digits between 1 to 6. Each 5-digit number
# is separated by a newline
function getRandomNumber(){
curl -s "http://www.random.org/integers/?num=25&min=1&max=6&col=5&base=10&format=plain&rnd=new" | tr -d '\t'
}
# select five words from the diceware wordlist using the
# random numbers generated from getRandomNumber function
function getPassword(){
for i in $(getRandomNumber); do
grep $i diceware.txt | cut -f2
#echo ' '
done
}
echo $(getPassword)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment