May 17, 2011

File protection on my iMac

I like to keep a text file around with my passwords. I find this necessary because I have dozens of online accounts and it's hard to keep track. As such, I've always wanted to encrypt this file, so that if my computer was ever compromised, whether hacked or even stolen, at least my passwords would be safe. Googling for terms like "mac encrypt files" sent me to sites that recommended I create a separate disk image with file encryption enabled, then save my precious file in this new storage partition.

Ridiculous, right? Who's going to go through that hassle just for one file? I certainly wasn't.

Fast forward to today and I've discovered the perfect way to encrypt a single file, using an application called gpg. Not sure if there's a GUI version, but using the command line was simple. Here's an example of the command I used:

> gpg -c my_password_file.txt

It'll ask you to enter a passphrase. Enter a password and remember it. This should produce a file called my_password_file.txt.gpg. The .gpg file is your password protected file. Delete your original password file, and you're all set.

To decrypt:
> gpg my_password_file.txt.gpg

Again it'll ask you for a passphrase. Enter the same password that you used when encrypting. Voila! You should now have your original my_password_file.txt file back.

Some disclaimers:
  • This method is only as secure as your password. Keep it secret.
  • Logically, this doesn't seem foolproof against a brute force attack. I don't know the technical details of how gpg was implemented so I can't say for sure. It'll always help to use a strong password.

No comments:

Post a Comment