Sipsmi's Blog

Techno ramblings of a cynical engineer

Posts Tagged ‘AES

AES256 with gpg

leave a comment »

I needed to quickly encrypt some files, and symmetric encryption was more than adequate. I considered that AES256 would be a nice algorithm (good enough for the NSA good enough for me 🙂 ).

So there are the are some AES 256 tools however the GNU version of PGP does include symmetric encryption. To define the algorithm and to do this nicely preserving the original file (only encrypt the one going to the backup store) involves a few fiddly command-line parameters that  I didn’t want to have to retype.  Declaring an alias was also a little bit of a nause with passing multiple parameters.

In the end I defined a shell function which does what I wanted to do whilst also allowing the passing parameters and preservation of the original file. These is a short function I added to my .bashrc

function enc()
 {
      gpg -v --symmetric --cipher-algo aes256 -o $1.gpg $1
 }
 function dec()
 {
       gpg -v -d -o $1 $1.gpg
 }

so now I can simply encrypt file, say hello.txt, using the following:

        enc hello.txt

and also decrypted from its hello.txt.gpg form using the this line:

        dec  hello.txt

notice no .gpg required to be specified as the encrypted version is implied from the original file-name.

 

Disclaimer: This code is from a hardware engineer turned hacker, it most likely aint pretty, it most likely can be done better but …. it works.

Written by sipsmi

September 19, 2013 at 9:13 am

Posted in GNU/Linux

Tagged with , , , ,