Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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[@]}`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement