Encrypting/Decrypting a single file in Ubuntu 12.04 LTS

A simple way to encrypt a single file is with openssl:

openssl des3 < youfile.txt > yourfile.txt.des3

This will prompt you for a passphrase, which you will need to enter later when decrypting the file.

openssl des3 -d < yourfile.txt.des3 > yourfile.txt.decrypted

To make this "graphical" you could put it in a Nautilus script and make it accessible from the context menu. (See the docs of Nautilus for that.)

UPDATE

des3 is just an example. Run openssl list-cipher-algorithms to see the full list of ciphers.


Lets assume that a person wants to encrypt a file called 'message.txt':

1. Encrypting a file using GPG, for personal use

I. Using a passphrase to encrypt the file (and not the private key)

I.i. The command: gpg -c message.txt does it; it asks for a password (and a password confirmation) and generates an encrypted 'message.txt.gpg', which is binary.

I.ii. If you want to generate an ASCII encrypted file, which is base64(i think) of that file, you can use gpg -c --armor message.txt This will generate an 'message.txt.asc', which is the same as the generated by the command before, but base64 coded, i.e., the encrypted file in text mode (.asc, not binary as .gpg would be).

II. Using a private key to encrypt a file

II.i. If you want to encrypt a file using your key, instead of only a passphare, use the command gpg -e -r 'yourname' message.txt. The argument 'yourname' should contain a part of the name that you used to create the private key. If you dont give the -r parameter, gpg will ask for it. You can type our name then (the same that you would type on command line).

II.ii. Point II.i would give you a binary file. If you want to get an ASCII file, use --armor. gpg -e -r 'yourname' --armor message.txt.

2. Decrypting the file encrypted with GPG

To decrypt, the file, use the command gpg -d --output OUTPUTFILE message.txt.gpg. This will ask for the passphrase and then decrypt the file message.txt.gpg to OUTPUTFILE, if the passphrase is correct. This passhrase is that which you used directly (point I., the -c parameter), or through your private key (point II., the -e parameter) This works for both binary (.gpg) or ascii (.asc) files. If you supress the --output FILE, it is outputted to console (stdout), then you can do this also, that is, redirect it to a file: gpg -d message.txt.gpg > OUTPUTFILE.txt Both do the same. 8 )


Try http://www.aescrypt.com/ it works great.