Created
January 2, 2022 19:46
-
-
Save rastreador/3c2830f4ac5dc739118bd8a6f241049d to your computer and use it in GitHub Desktop.
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 | |
echo "SCRIPT DE CIFRADO" | |
echo "-----------------" | |
echo "" | |
echo -n "Clave de encriptacion: " | |
read -s CLAVE | |
echo "" | |
echo -n "Texto a cifrar: " | |
read -s TEXTO | |
echo "" | |
SALIDA=$(echo $TEXTO | openssl aes-256-cbc -pbkdf2 -a -A -salt -pass pass:$CLAVE) | |
#echo $SALIDA | |
echo "" | |
echo -n "Repita la clave para verificar el cifrado:" | |
read -s CLAVE2 | |
echo "" | |
TEXTO_DESCIFRADO=$(echo $SALIDA | openssl aes-256-cbc -d -pbkdf2 -a -A -salt -pass pass:$CLAVE2) | |
echo "" | |
if [ "$TEXTO_DESCIFRADO" == "$TEXTO" ] | |
then | |
echo "Clave correcta. Copie el texto cifrado:" | |
echo $SALIDA | |
echo "" | |
read -n 1 -s -r -p "Pulsa cualquier tecla para terminar y borrar la pantalla" | |
clear | |
else | |
echo "Clave incorrecta" | |
echo "" | |
fi | |
unset CLAVE | |
unset CLAVE2 | |
unset SALIDA | |
unset TEXTO | |
unset TEXTO_DESCIFRADO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment