First step is to create a script for the compression + encryption. You could to call it for instance: “encrypt”.
#!/bin/bash
tput sc
while [ -s $pass ] || [ $pass '!=' $pass2 ]; do
read -s -p "Enter Passphrase: " pass;
tput rc;
read -s -p "Re-Enter Passphrase: " pass2;
tput el1;
tput rc;
done;
for file in $@; do
tar -cf - $file | gpg -c --passphrase $pass > $file.gpg;
srm $file;
done
Next, if you want decrypt a file will be necessary to run another script defined as:
#!/bin/bash
tput sc;
while [ -s $pass ]; do
read -s -p "Enter Passphrase: " pass;
tput el1;
tput rc;
done;
for file in $@; do
if [ $? -eq 0 ]; then
srm $file;
else
echo Failed to Decrypt;
echo [password might be wrong];
fi;
done;
Finally, after the script definitions, you could run when you wish encrypt or decrypt a file:
encrypt filename
decrypt filename
Enjoy it!
Nessun commento:
Posta un commento