From 56b5329703eff3d02017fd7ce545bba3b0b4dc26 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 19 Jun 2018 10:19:59 +0200 Subject: passwords with special characters should always start and end with normal characters --- bin/bin/makepass | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/bin/makepass b/bin/bin/makepass index 4aa05cd..596c6e5 100755 --- a/bin/bin/makepass +++ b/bin/bin/makepass @@ -20,6 +20,8 @@ function makepass { local l=$1 local words + local first + local last 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 @@ -34,7 +36,10 @@ function makepass { echo "Passwords with special characters:" for i in {1..6}; do [ "$1" = "" ] && l=$(shuf -i 16-64 -n 1) - < /dev/urandom tr -dc '!#$%&/()=?+-_,.;:<>[]{}|\@*^A-Z-a-z-0-9' | head -c${1:-$l};echo; + first=$(< /dev/urandom tr -dc A-Za-z | head -c 1) + words=$(< /dev/urandom tr -dc '!#$%&/()=?+-_,.;:<>[]{}|\@*^A-Z-a-z-0-9' | head -c${1:-$l} | cut -c 3-) + last=$(< /dev/urandom tr -dc A-Za-z | head -c 1) + echo "${first}${words}${last}" done | column if [ -r "${MAKEPASS_WORDLIST}" ]; then -- cgit v1.2.3