From 8b8c1884e2f4744ad170442b23aed13ff55bf017 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Mon, 14 May 2018 16:52:49 +0200 Subject: moving around stuff --- bin/bin/makepass | 22 ++++++++++++++++++++++ bin/bin/makepass.sh | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) create mode 100755 bin/bin/makepass delete mode 100755 bin/bin/makepass.sh diff --git a/bin/bin/makepass b/bin/bin/makepass new file mode 100755 index 0000000..cd29da8 --- /dev/null +++ b/bin/bin/makepass @@ -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 diff --git a/bin/bin/makepass.sh b/bin/bin/makepass.sh deleted file mode 100755 index cd29da8..0000000 --- a/bin/bin/makepass.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/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