As well as being a valuable library for web services, MCrypt is a simple tool for encrypting/decrypting files. As per a request from one of my coffee buying supporters, here’s how to build it on Mac OS X!
Dr Hook sang a song called Levitate
Before we get into it, if you don’t remember how to build software on *nix, here’s the procedure for installing in
/usr/local as root:
% sudo -s # tar xzvf [app][version].tar.gz # cd [app][version] # ./configure # make install clean
This is the way you do it ~ Dr Hook, Levitate
MCrypt comes in two parts, the command interface and the libmcrypt library. Download the library tarball from its SourceForge page, and build to taste. Alternatively you can install it from Homebrew with
brew install mycrypt[sic].
Download the MCrypt tarball from SourceForge, and build to taste!
Look at me taking off! ~ Dr Hook, Levitate
MCrypt works in the shell by encrypting files with a cipher of your choice, and spitting out a name appended with mc, presumably because the programmer was a fan of MC Hammer and because encryption means bad guys can’t touch this. No wait, its short for MCrypt, never mind.
For example, my favourite cipher is Twofish so here’s how we would encrypt a dodgy photo you wouldn’t want people to see. You’ll be prompted for a password.
% mcrypt -a twofish photo.jpg
The procedure to decrypt is basically the same.
% mcrypt -d photo.jpg.mc
Of course regular encryption recommendations apply. Decrypting files to a local drive or volume that isn’t itself encrypted could potentially allow future people to gain access to your plaintext. Use strong passwords. Employ liberal amounts of common sense. And so on :).