Im trying to make a bash script that will ask the name of the user, favorite food and the current date and save these to the variables food, date and name a random password will then be generated. When the user forgets the password all he has to do is enter the same name (userrecovery), favorite food (foodrecovery) and the date (daterecovery) when the password was generated and the password should be shown. The code i use to generate a random password:
Code:
choose() { echo ${1:RANDOM%${#1}:1} $RANDOM; }
pass="$({ choose '!@#$%^\&'
choose '0123456789'
choose 'abcdefghijklmnopqrstuvwxyz'
choose 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in $( seq 1 $(( 4 + RANDOM % 8 )) )
do
choose '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
done
} | sort -R | awk '{printf "%s",$1}')"
I tried something like:
Code:
if [ $food=$foodrecovery -a $date=$daterecovery -a.... ]
echo $pass
This works but when i close the script and reopen it will generate a new password which it shouldnt.