Sunday, November 23, 2008

Symmetric key encryption and decryption using gpg

You want to encrypt a file so only you can decrypt it with a password.


Solution

$ gpg -c filename

Symmetric encryption (-c) is the simplest way to encrypt a file with gpg: just provide a password at encryption time. To decrypt, provide the password again.
By default, encrypted files are binary. To produce an ASCII text file instead, add the -a (armor) option: $ gpg -c -a filename

Binary encrypted files are created with the suffix .gpg, whereas ASCII encrypted files have the suffix .asc.

You want to decrypt a file that was encrypted with GnuPG.

Solution

Assuming the file is myfile.gpg, decrypt it in place with:
$ gpg myfile.gpg creates myfile

Decrypt to standard output:
$ gpg --decrypt myfile.gpg

Decrypt to a named plaintext file:
$ gpg --decrypt --output new_file_name myfile.gpg


source Richard E silvermann

No comments:

Post a Comment