diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bin/makepass.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/bin/makepass.sh b/bin/bin/makepass.sh new file mode 100755 index 0000000..cd29da8 --- /dev/null +++ b/bin/bin/makepass.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env zsh +# Copyright (c) 2018 Dennis Eriksen • d@ennis.no + +# makepass-function +function makepass { + local l=$1 + # if $l is not a number, then exit + [[ ! $l = <-> ]] && [[ ! "$l" == "" ]] && echo "not a number" && return 1 + # if $1 is actually empty, set $l to random value for each output + for i in {1..10}; do + [ "$1" = "" ] && l=$(shuf -i 8-44 -n 1) + < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-$l};echo; + done; + for i in {1..5}; do + [ "$1" = "" ] && l=$(shuf -i 16-64 -n 1) + < /dev/urandom tr -dc '!"#$%&/()=?+-_,.;:<>[]{}|\@*^A-Z-a-z-0-9' | head -c${1:-$l};echo; + done; +} + +makepass "${@:-}" + +# vim:syntax=sh filetype=sh |