Wednesday, 29 April 2009

Simple File Encryption

If you have a few confidential files, and you want to keep its privacy, you can use the gpg package (GNU Privacy Guard) which is a version of PGP (Pretty Good Privacy) distributed under GPL license. This package almost have been included on every Linux distro. It offers two modes of encryption: asymmetric (public key) and symmetric.

Imagine that you have a very important specification of new project you have worked on, saved in the file named PROJECT.pdf, and you want to hide it from unauthorised access. In order to do thus, use:

$ gpg --output Cipher --symmetric --cipher-algo TWOFISH PROJECT.pdf

gpg will prompt you for a password/passphrase that will be the key for securing your data. Type it and confirm. It should be as complicated as possible, but also easy to remember.

Let's walk through the command we entered. We told gpg to encrypt the PROJECT.pdf file using symmetric encryptin (--symmetric) and the TWOFISH cipher algorithm (--cipher-algo TWOFISH). Without the last option, gpg would use the default cipher, CAST5. the output will be stored in Cipher file (--output Cipher). You should be aware that, in case the given output file exists, the program will ask if it should be overwritten.

If you want to decrypt your file, use:

$ gpg --output PROJECT.pdf --decrypt Cipher

The --decrypt Cipher option means decrypt the file named Cipher whereas --output PROJECT.pdf specifies the ouput file name. gpg will automatically recognise the cipher that was used and will prompt for a password.



Reference:
1.Hakin9 Magazine, January 2005. www.hakin9.org.
2.GnuPG 1.4.9 Manual.

No comments: