Last active
December 7, 2022 17:15
-
-
Save ScratchyCode/7f5a61e6fd201a1a8abd88fc3826861e to your computer and use it in GitHub Desktop.
Cifra e/o decifra agilmente un messaggio con AES in modalità CBC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# cattura CTRL+Z | |
trap '' SIGTSTP | |
# display messaggio e metti in pausa | |
pause(){ | |
local m="$@" | |
echo "$m" | |
read -p "Premi [INVIO] per continuare..." key | |
} | |
# chiave di sessione | |
echo "Inserisci la password di sessione: " | |
read chiave | |
# loop | |
while : | |
do | |
# dispay menu | |
clear | |
echo "**************" | |
echo "* MENU *" | |
echo "**************" | |
echo "1) Cifrare" | |
echo "2) Decifrare" | |
echo "3) Esci" | |
echo "-----------------------------------------" | |
read -r -p "Inserisci il numero dell'opzione [1-3]: " opzione; | |
case $opzione in | |
1) echo "Inserisci frase da cifrare: "; | |
read frase; echo "Testo cifrato: "; | |
echo $frase | openssl enc -aes-256-cbc -base64 -A -k $chiave 2>/dev/null; | |
pause;; | |
2) echo "Inserisci frase da decifrare: "; | |
read frase; | |
echo "Testo decifrato: "; | |
echo $frase | openssl enc -aes-256-cbc -d -base64 -A -k $chiave 2>/dev/null; | |
pause;; | |
3) break;; | |
*) echo "ERRORE: selezionare l'opzione da 1 a 3"; | |
pause;; | |
esac | |
done | |
unset chiave | |
echo "Fine sessione." | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment