-
Notifications
You must be signed in to change notification settings - Fork 1
/
Caesar cipher.sh
25 lines (23 loc) · 770 Bytes
/
Caesar cipher.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
# Começamos definindo: faremos com todas as letras do alfabeto, de a-z e maisculas.
# Na segunda parte, temos: esse 'd' significa que o a vai mudar para d, logo entendendo que mudou 3 posições e terá que fazer isso no resto da string
# O a-c significa: quando for para o z, ele vai ter que recomeçar, de certa forma, sabe?
cat << EOF
[1] - 1 para por uma string
[1] - 2 para por um arquivo
EOF
echo -e "\n"
read -p "Digite seu valor : " valor
if [ $valor == 1 ];
then
read -p "Digite a string: " string
echo "$string" | tr 'a-zA-Z' 'd-za-cD-ZA-C'
elif [ $valor == 2 ];
then
read -p "Digite o nome do arquivo: " arquivo
cat "$arquivo" | tr 'a-zA-Z' 'd-za-cD-ZA-C'
else
echo "Valor digitado não aceito.."
fi
#d-za-c
#D-ZA-C