aboutsummaryrefslogtreecommitdiffstats
path: root/makepass.bash
diff options
context:
space:
mode:
Diffstat (limited to 'makepass.bash')
-rwxr-xr-xmakepass.bash13
1 files changed, 7 insertions, 6 deletions
diff --git a/makepass.bash b/makepass.bash
index 04d4f49..c2edf82 100755
--- a/makepass.bash
+++ b/makepass.bash
@@ -21,19 +21,21 @@ function makepass {
MAKEPASS_WORDLIST=${MAKEPASS_WORDLIST:-/usr/share/dict/words}
# if $l is not a number, then exit
[[ ! $l =~ ^[0-9]+$ ]] && [[ ! "$l" == "" ]] && echo "not a number" && return 1
+ (( l <= 1 || l > 255 )) && echo "Argument must be between 0 and 255" && return 1
# if $1 is actually empty, set $l to random value for each output
+
echo "Normal passwords:"
- for i in {1..10}; do
+ for _ in {1..10}; do
[ "$1" = "" ] && l=$(shuf -i 8-44 -n 1)
- head -n10 /dev/urandom | tr -dc _A-Z-a-z-0-9 | cut -c-${1:-$l};
+ head -n10 /dev/urandom | tr -dc _A-Z-a-z-0-9 | cut -c-"${1:-$l}";
done | column
echo ""
echo "Passwords with special characters:"
- for i in {1..6}; do
+ for _ in {1..6}; do
[ "$1" = "" ] && l=$(shuf -i 16-64 -n 1)
first=$(head -n10 /dev/urandom | tr -dc A-Za-z | cut -c-1)
- words=$(head -n10 /dev/urandom | tr -dc '!#$%&/()=?+-_,.;:<>[]{}|\@*^A-Z-a-z-0-9' | cut -c-${1:-$l})
+ words=$(head -n10 /dev/urandom | tr -dc '!#$%&/()=?+-_,.;:<>[]{}|\@*^A-Z-a-z-0-9' | cut -c-"${1:-$l}")
last=$(head -n10 /dev/urandom | tr -dc A-Za-z | cut -c-1)
echo "${first}${words}${last}"
done | column
@@ -42,7 +44,7 @@ function makepass {
echo ""
echo "Passphrases:"
- for i in {1..5}; do
+ for _ in {1..5}; do
words=$(shuf -n 8 "${MAKEPASS_WORDLIST}" | tr '\n' '-' | tr -dc '_A-Z-a-z-0-9')
echo "${words:0:-1}"
done;
@@ -52,4 +54,3 @@ function makepass {
makepass "${@:-}"
## END OF FILE #################################################################
-# vim:syntax=bash filetype=bash