Simple File Encryption
This morning I decided to turn on two-factor authentication on my GitHub account using the Authy app for my iPhone. I've been able to use it for different accounts, and it's always mine - not the company I work for, and while I've been using SMS for a while on GitHub - and others, I've just decided that it's probably a good thing to get moving on this = given the privacy issues that we are all reading about these days.
The thing that I needed was a simple file encryption bash script/function so that I could store the recovery tokens in a file without having to worry about it getting snatched. So now I've got it. The code is based on openssl, and it's pretty simple:
# # These are simple functions to encrypt and decrypt files so that I don't # have to hassle with extreme things in order to secure one file at a time. # They use openssl to do the work, and it's pretty simple. # function jack { openssl des3 -in "$1" -out "$1.enc" } function unjack { openssl des3 -d -in "$1" -out `basename "$1" .enc` }
and this simply allows me to encrypt a file and it adds .enc on the end of the filename, and then I can decrypt it as well, stripping that addition as well. Nothing fancy, but it really works just great.