pick a good password.
# take in a file and output an encrypted one
function encrypt() {
# take in a file and output a new one with a `.enc` extension
openssl rc4 -in "$1" -out "$1".enc
echo "$1.enc created"
}
# reverse of encrypt()
function decrypt() {
FILENAME="$1" # save the old filename
# decrypt the file and save it to a file with no `.enc` extension
openssl rc4 -d -in "$1" -out ${FILENAME%.*}
echo "$1 decrypted"
}
This still leave an "open" file when the file is encrypted. Remember to remove the file securely. You can use shred
or gshred
(for OSX). Here is the info from the --help
output of gshred:
Overwrite the specified FILE(s) repeatedly, in order to make it harder for even very expensive hardware probing to recover the data.
Here is the function that I found to be pretty good:
# overwrite 'my-unsafe-file.txt' 3 times, with zeros (nulls) and then remove the file
gshred --iterations=3 --zero --remove my-unsafe-file.txt
Note: I used RC4 instead of 3DES because it is faster (95% slower than RC4), but it is not as secure.
I'm a full-stack developer, co-organizer of PHP Vancouver meetup, and winner of a Canadian Developer 30 under 30 award. I'm a huge Open Source advocate and contributor to a lot of projects in my community. When I am not sitting at a computer, I'm trying to perfect some other skill.