From d42e669fed89978b1a966cd80bfdaa67cba0db73 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Thu, 10 May 2018 21:08:18 +0200 Subject: moving scripts out, and updating for stow --- bin/bin/makepass.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 bin/bin/makepass.sh 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 -- cgit v1.2.3