April 25, 2009

How to Encrypt and decrypt files with a password ?

Use gpg command, which is encryption and signing tool for Linux/UNIX like operating system (FreeBSD/Solaris).
GnuPG stands for GNU Privacy Guard and is GNU's tool for secure communication and data storage. It can be used to encrypt data and to create digital signatures. It includes an advanced key management facility.

1) To encrypt single file use command gpg as follows:

$ gpg -c filename

For example to encrypt myfinancial.info file

$ gpg -c myfinancial.info

Output:
Enter passphrase:
Repeat passphrase:
This will create a myfinancial.info.gpg file.
Option:
• -c : Encrypt with symmetric cipher.
Caution if you ever forgot your password aka passphrase, you cannot recover the data as it use very strong encryption.


2) To decrypt file use gpg command:

$ gpg myfinancial.info.gpg

Output:
gpg myfinancial.info.gpg
gpg: CAST5 encrypted data
Enter passphrase:


3)Decrypt file and write output to file gaurav.info.txt you can run command:

$ gpg myfinancial.info.gpg –o gaurav.info.txt

Remember if file extension is .asc then it is a ASCII encrypted file and if file extension is .gpg then it is a binary encrypted file.

No comments:

Post a Comment