openssl enc -aes-256-cbc -pbkdf2 -in toto.enc -out toto.txt
openssl enc -aes-256-cbc -pbkdf2 -in toto.txt -out toto.encrypted -pass pass:mot_de_passe
openssl enc -aes-256-cbc -pbkdf2 -d -in toto.encrypted -out toto.txt -pass pass:mot_de_passe
#!/bin/bash
if [ -z "$1" ]
then
echo "Le premier argument doit etre un mot de passe"
exit 1;
fi
for i in $(find -name \*.txt); do
echo "ENCRYPT: $i";
openssl enc -aes-256-cbc -pbkdf2 -in $i -out $i.encrypted -pass pass:"$1"
if [ $? -eq 0 ]
then
rm $i;
else
rm $i.encrypted;
fi
done
#!/bin/bash
if [ -z "$1" ]
then
echo "Le premier argument doit etre un mot de passe"
exit 1;
fi
for i in $(find -name \*.encrypted); do
FILE_OUT_NAME="${i/\.encrypted/}"
echo "DECRYPT: $FILE_OUT_NAME";
openssl enc -d -aes-256-cbc -pbkdf2 -in $i -out "$FILE_OUT_NAME" -pass pass:"$1"
if [ $? -eq 0 ]
then
rm "$i";
else
rm "$FILE_OUT_NAME";
fi
done
~/.local/share/nautilus/scripts
#!/bin/bash
CURRENT_DIR=`pwd`
CURRENT_FILE_PATH="${CURRENT_DIR}/${1}"
echo $CURRENT_FILE_PATH > /tmp/nautilus_script.txt
chmod +x ~/.local/share/nautilus/scripts/test.sh
#!/bin/bash
CURRENT_DIR=`pwd`
CURRENT_FILE_PATH="${CURRENT_DIR}/${1}"
if [[ -f $CURRENT_FILE_PATH ]]
then
ENCRYPTED_FILE_PATH="${CURRENT_FILE_PATH}.encrypted"
ENCRYPTION_PASSWORD="SECRET"
openssl enc -aes-256-cbc -pbkdf2 -in "${CURRENT_FILE_PATH}" -out "${ENCRYPTED_FILE_PATH}" -pass pass:$ENCRYPTION_PASSWORD
if [ $? -eq 0 ]
then
rm "${CURRENT_FILE_PATH}"
else
rm "${ENCRYPTED_FILE_PATH}";
fi
fi
#!/bin/bash
CURRENT_DIR=`pwd`
CURRENT_FILE_PATH="${CURRENT_DIR}/${1}"
if [[ -f $CURRENT_FILE_PATH ]]
then
FILE_OUT_NAME="${CURRENT_FILE_PATH/\.encrypted/}"
ENCRYPTION_PASSWORD="SECRET"
openssl enc -d -aes-256-cbc -pbkdf2 -in "${CURRENT_FILE_PATH}" -out "${FILE_OUT_NAME}" -pass pass:$ENCRYPTION_PASSWORD
if [ $? -eq 0 ]
then
rm "${CURRENT_FILE_PATH}"
else
rm "${FILE_OUT_NAME}";
fi
fi
chmod +x ~/.local/share/nautilus/scripts/decrypt ~/.local/share/nautilus/scripts/encrypt
💣️Limite: la valeur de la variable $ENCRYPTION_PASSWORD est facilement trouvable.
💣️Ce script ne fonctionne que pour des fichiers simples, pas avec des dossiers.
💡️Pour chiffrer un dossier, l'astuce est de le zipper avant de le chiffrer.
Voir ici : https://www.reddit.com/r/crypto/comments/4g5i9q/how_do_i_use_openssl_to_encrypt_a_folder/