Thursday, June 25, 2009

Encrypting and Decrypting a file in Linux

Encrypting a file in Linux :

To encrypt single file,
use command gpg as follows:$ gpg -c filename
To encrypt myfinancial.info file,
type the command:$ 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.

Decrypting a file in Linux:

To decrypt file use gpg command:
$ gpg myfinancial.info.gpg

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

Decrypt file and write output to file vivek.info.txt you can run command:
$ gpg myfinancial.info.gpg –o vivek.info.txt

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

No comments:

Post a Comment