Encrypt/Decrypt a file
Either GPG or OpenSSL can be used to encrypt/decrypt a file with a password.
Encrypt
Let's say you have a directory /var/svn (a Subversion repository) that you have put into file called backup.tar, and you want to encrypt it before transmitting over the Internet.
Using GPG
To encrypt an already-created file:
gpg -c -o backup.tar.gpg backup.tar
You will be asked to enter a “passphrase” twice, then the encrypted file will be created. GPG compresses the data, so don't bother using gzip or bzip2, just make a plain tar file.
To pipe TAR output to GPG:
tar -c /var/svn | gpg -c -o backup.tar.gpg
Using SSL
To encrypt an already-created file:
openssl des3 -salt < backup.tar > backup.tar.ssl
To pipe TAR's output directly to OpenSSL:
tar -c /var/svn | openssl des3 -salt > backup.tar.ssl
In my tests of a 45MB Subversion directory, SSL actually made the smallest backup (smaller than bzip2 even).
Decrypt
Using GPG
gpg backup.tar.gpg
Using SSL
cat backup.tar.ssl | openssl des3 -d -salt |tar -xv