Created
March 14, 2016 22:44
-
-
Save pkutzner/1bc69cef3daeaf1d1c09 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# XKCD/diceware-style password generator that ensures at least one | |
# upper-case character is present and that each word has a | |
# minimum of 6 characters. Suitable for adding to your .aliases | |
# file. | |
dicepass() { | |
while true; do | |
local xpass=$(look . | grep -oE "^[A-Za-z]{6,}$" | shuf | head -4 | xargs) | |
if echo "$xpass" | grep -E "[A-Z]" >/dev/null 2>&1; then | |
echo "$xpass" | |
unset xpass | |
break | |
fi | |
done | |
} | |
# "Short word" (4-6 characters) XKCD/diceware-style password generator. | |
sdicepass() { | |
while true; do | |
local xpass=$(look . | grep -oE "^[A-Za-z]{4,6}$" | shuf | head -4 | xargs) | |
if echo "$xpass" | grep -E "[A-Z]" >/dev/null 2>&1; then | |
echo "$xpass" | |
unset xpass | |
break | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment