Encrypting and decrypting files

Create a shellscript called enc with the following line:

  openssl enc -aes-256-cbc -salt -in $1 -out $1.enc

Then create a shellscript called dec with the following line:

  openssl enc -d -aes-256-cbc -in $1 -out `basename $1 .enc`

Almost all Linux distributions use the OpenSSH/OpenSSL libraries, so these shellscripts should work universally.

Don't forget to use a wiping tool (not plain "rm") for the file you just encrypted, otherwise it'll be trivial for an attacker or nosy system administrator to get the original file through undeleting the files.

Tip: if you need to encrypt a whole directory, tar and gzip (or bzip2) it first. Compression before encryption is always a good idea.