Created
October 15, 2015 18:36
-
-
Save l0s/26e4f7d7ce53b4b2d27b to your computer and use it in GitHub Desktop.
XKCD password generator for BSD / Mac OS X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # adapted from: https://pthree.org/2015/09/05/password-generation-in-the-shell/ | |
| # which is inspired by: https://xkcd.com/936/ | |
| gen-xkcd-pass() { | |
| [ $(echo "$1"|grep -E "[0-9]+") ] && NUM="$1" || NUM=1 | |
| DICT=$(LC_CTYPE=C grep -E "^[a-zA-Z]{3,6}$" /usr/share/dict/words) | |
| for I in $(seq 1 "$NUM"); do | |
| WORDS=$(echo "$DICT"|gshuf -n 6|paste -sd ' ' -) | |
| XKCD=$(echo "$WORDS"|sed 's/ //g') | |
| echo "$XKCD ($WORDS)"|awk '{x=$1;$1="";printf "%-36s %s\n", x, $0}' | |
| done | column | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment