aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDennis Eriksen <d@ennis.no>2018-06-19 10:19:59 +0200
committerDennis Eriksen <d@ennis.no>2018-06-19 10:19:59 +0200
commit56b5329703eff3d02017fd7ce545bba3b0b4dc26 (patch)
tree983b1698c27c61f7da9b074b9506c30dc37b0950 /bin
parentlets not print a header if we dont have a wordlist (diff)
downloadmakepass-56b5329703eff3d02017fd7ce545bba3b0b4dc26.tar.gz
passwords with special characters should always start and end with normal characters
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bin/makepass7
1 files changed, 6 insertions, 1 deletions
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