Quick and dirty password generator for macOS
#!/bin/bash | |
# Generates readable, word based passwords with random numbers attached. | |
# Example pass: Foo73-bar22 | |
# Passwords take 'centuries' to crack according to https://github.com/dropbox/zxcvbn | |
DICT_FILE='/usr/share/dict/words' | |
#DICT_FILE_LENGTH=`python -c "import sys;num_lines = sum(1 for line in open('/usr/share/dict/words'));print num_lines"` | |
DICT_FILE_LENGTH='235886' | |
RANDOM_NUM=`od -vAn -N4 -tu < /dev/urandom` | |
RANDOM_NUM2=`od -vAn -N4 -tu < /dev/urandom` | |
WORD_ONE_IDX=`echo "$RANDOM_NUM % $DICT_FILE_LENGTH" | bc` | |
WORD_TWO_IDX=`echo "$RANDOM_NUM2 % $DICT_FILE_LENGTH" | bc` | |
WORD_ONE=`sed -n ''"$WORD_ONE_IDX"'p' < $DICT_FILE` | |
WORD_TWO=`sed -n ''"$WORD_TWO_IDX"'p' < $DICT_FILE` | |
NUM_ONE=`echo $((1 + RANDOM % 99))` | |
NUM_TWO=`echo $((1 + RANDOM % 99))` | |
# Uppercase the first letter. | |
WORD_ONE=`echo $WORD_ONE | perl -ne 'print ucfirst'` | |
echo "$WORD_ONE$NUM_ONE-$WORD_TWO$NUM_TWO" | tee /dev/tty | pbcopy | |
echo "Copied above password to clipboard." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Web equivalents here: