Skip to content

Instantly share code, notes, and snippets.

@wuthmone
Created August 25, 2016 09:06
Show Gist options
  • Save wuthmone/e3969bb01d44cf0c5d5e0b02b732259d to your computer and use it in GitHub Desktop.
Save wuthmone/e3969bb01d44cf0c5d5e0b02b732259d to your computer and use it in GitHub Desktop.
#!/bin/bash
declare -a key # declare key as array
echo "Please key in four key"
read key[0,1,2,3]
i=0
for c in "${key[@]}"
do
lkey[$i]=${c,,}
i=$((${i} + 1))
done # translate all alphabet to lower character,lkey
function let2num {
for i in `echo "$1" | grep -o . ` ; do
echo $((`printf '%d' "'$i"` -97))
done
}
echo "What is your option"
echo "1) Encryption"
echo "2) Decryption"
echo "3) Exit"
read option;
if [ "$option" -eq "1" ]; then
echo "You selected Encryption"
elif [ "$option" -eq "2" ]; then
echo "You selected Decrypion"
elif [ "$option" -eq "3" ]; then
echo "You selected Exit,program will exit soon"
exit 0
else
echo "Invalid input,program will terminated soon"
exit 0
fi
echo "The key is ${lkey[@]}"
echo `let2num ${lkey[@]}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment