Personal Encryption

I finally took the time to search for some personal encryption while waiting for a long svn merge and commit. I wanted a small tool, preferably a single executable, works on multiple platforms, to encrypt files with keys. GPG initially felt a little too obscure to me, until I found this guide.

In short:

  • gpg --gen-key and answer the prompts to generate a key pair. Make sure your remember your passphrase.
  • gpg -k to list the keys.
  • gpg -r [keyname] -e [clearfile] to encrypt the file using the particular key. By default the output is the same clearfile name with .gpg extension. Use -o option to change it.
  • gpg -o [clearfile] -d [encryptedfile] to decrypt the file. -o option is needed here because this command outputs to console by default.
  • gpg -a -r [keyname] -o [keyfile] --export-secret-keys to export the secret key. I need the same key on another computer to decrypt the contents. The -a option is synonymous with –armor, which generates a text representation instead of binary.
  • gpg --import [keyfile] to import the key on to another computer.

A bonus feature was it actually compresses as it encrypts. I was thinking of manually scripting it to do so.

Leave a Reply