Skip to content

Instantly share code, notes, and snippets.

@milleniumbug
Created August 4, 2017 03:15
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 milleniumbug/4059b7a713346e02305bc828f271fa17 to your computer and use it in GitHub Desktop.
Save milleniumbug/4059b7a713346e02305bc828f271fa17 to your computer and use it in GitHub Desktop.
Generate a passphrase from a dictionary file (like /usr/share/dict/english)
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: passphrasegen.sh path-to-dictionary number-of-words"
exit 1
fi
# TOFIX: the actual number of possible passwords is not N^M, but N*(N-1)*(N-2)*...*(N-M+1)
shuf -n "$2" "$1" --random-source /dev/urandom | paste -d\ --serial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment