bash - how to make this password generator generate random length password -



bash - how to make this password generator generate random length password -

im new bash scripting , need help this. have password generator script , generates 8 character long password. i've been trying create generate random length couldn't it. can bash scripting knowledge give me suggestion on how this?

here script

if [ $# -eq 0 ]; num=("0" "1" "2" "3" "4" "5" "7" "8" "9") special=("@" "#" "$" "%" "*" "-" "+") upper=(a b c d e f g h j k l m n o p q r s t u v w x y z) lower=(a b c d e f g h j k l m n o p q r s t u v w x y z) length=(0 1 2 3 4 5 7 8) length2=${#length[*]} #${lower[$((random%length2))]) lower2=${#lower[*]} #${lower[$((random%lower2))]} upper2=${#upper[*]} #${upper[$((random%upper2))]} num2=${#num[*]} #${num[$((random%num2))]} special2=${#special[*]} #${special[$((random%special2))]} abc=`#${lower[$((random%lower2))]}` echo "$word${special[$((random%special2))]}${num[$((random%num2))]}${lower[$((random%lower2))]}${upper[$((random%upper2))]}${lower[$((random%lower2))]}${upper[$((random%upper2))]}${lower[$((random%lower2))]}${upper[$((random%upper2))]}$length" | fold -w 1 | shuf | tr -d '\n' echo fi

bash's $random can't used generate random passwords because it's predictable.

to generate more secure password of pseudo-random length, utilize like

tr -cd 'a-za-z0-9@#$^*-+' < /dev/urandom | head -c $((random % 8 + 16))

of course of study appreciate want learning purposes, people later google "how generate random length passwords in bash" shouldn't insecure algorithm first result.

bash

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -