Tuesday, September 13, 2011

How to encrypt and decrypt a file in Linux

You can use command gpg to encrypt and decrypt a file in Linux

Following is an example of how you can encrypt a file using gpg
     gpg -c test.txt
This command will ask for a passwphrase and on successful execution will create file test.txt.gpg

Following is an example of how you can decrypt a file using gpg
   gpg -d test.txt.gpg > test.txt.tmp
NOTE: Do *not* decrypt file to test.txt because if you accidently provided wrong passphrase , decryption will fail and file test.txt will be empty and if you forgot the passphrase, there is no way to receover test.txt file

No comments:

Post a Comment