diceware.sh 546 B

1234567891011121314151617
  1. #!/usr/bin/env bash
  2. MOTS=$(echo "$1" | grep -E "^\-?[0-9]+$")
  3. # Default to 6 words passphrase
  4. if [[ "$MOTS" == "" ]]; then MOTS=6; fi
  5. WORDCOUNT=${1-$MOTS}
  6. # Download the wordlist
  7. # wget -nc -O ~/.diceware-wordlist http://world.std.com/%7Ereinhold/diceware.wordlist.asc 2> /dev/null
  8. # print a list of the diceware words
  9. cat ./shell/diceware-wordlist.txt |
  10. awk '/[1-6][1-6][1-6][1-6][1-6]/{ print $2 }' |
  11. # randomize the list order
  12. shuf --random-source=/dev/urandom |
  13. # pick the first n words
  14. head -n ${WORDCOUNT} |
  15. # pretty print
  16. tr '\n' ' '
  17. echo