Created
November 25, 2017 17:48
-
-
Save andreacfromtheapp/d95e3c1d644c7ead3101c15989290e66 to your computer and use it in GitHub Desktop.
a wrapper script around https://linux.die.net/man/1/apg
This file contains 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 | |
if ! which apg 2>&1>/dev/null; then | |
echo -e "\nYou need 'apg' for this script to do its job\n" | |
exit 127 | |
fi | |
if [[ $# == 0 ]]; then | |
echo "You need to provide how many password(s) you want to generate (and optionally how long hte passwords should be)."; | |
echo "E.g: ./${0##*/} 1 -- this will generate 1 password only with the default length of 16 characters."; | |
echo "E.g: ./${0##*/} 3 32 -- this will generate 3 passwords with a length of 32 characters."; | |
echo "You can use symbols in the password generation if you specify \"-s\" as third parameter"; | |
exit 1 | |
fi | |
if [[ -n $2 ]]; then | |
plength=$2; | |
else | |
plength=16; | |
fi | |
pflags="NCL"; | |
if [[ -n $3 ]]; then | |
if [[ $3 == "-s" || $3 == "-S" ]] ; then | |
pflags="NCLS"; | |
else | |
echo "Use -s or -S for salting!" | |
exit 99 | |
fi | |
fi | |
apg -a 1 -n $1 -m $plength -x $plength -M $pflags -E ":.\`\/~#$<>\!&|\\" -s | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment