PGP uses public-key cryptography for encryption and decryption. After installing GPG, you would first need to generate a GPG public-private key pair. If you want to send an encrypted document to someone, you would need to encrypt the document using the recipient’s public key and send it to her.
How to encrypt a file with GPG?
To send an encrypted document to someone, you would need to encrypt the document with the recipient’s public key :
# gpg --armor --output output.asc --encrypt --recipient <recipient-userid> <file>
Here, the document file.txt will be encrypted using the recipient’s public key, and the ASCII-armored output will be saved in output.asc.
You can now send output.asc to the recipient. Only the intended recipient can decrypt the document using her private key. As no one else other than the intended recipient possesses the required private key, only the intended recipient would be able to decrypt the document.
How to decrypt a file with GPG?
The recipient can retrieve the original document using her private key using the following command:
# gpg --output file.txt --decrypt output.asc
How to encrypt a file with a GPG symmetric key?
You can also use a symmetric key to encrypt a document. If you encrypt a document using a symmetric key, one would need to use the same symmetric key to decrypt the document. For the symmetric key, please use a passphrase different from that of your private key.
# gpg --armor --output output.asc --symmetric file.txt
How to decrypt a file with a GPG symmetric key?
![Share on Facebook Facebook](https://www.thesecuritybuddy.com/wordpress/bdr/plugins/social-media-feather/synved-social/image/social/regular/64x64/facebook.png)
![Share on Twitter twitter](https://www.thesecuritybuddy.com/wordpress/bdr/plugins/social-media-feather/synved-social/image/social/regular/64x64/twitter.png)
![Share on Reddit reddit](https://www.thesecuritybuddy.com/wordpress/bdr/plugins/social-media-feather/synved-social/image/social/regular/64x64/reddit.png)
![Pin it with Pinterest pinterest](https://www.thesecuritybuddy.com/wordpress/bdr/plugins/social-media-feather/synved-social/image/social/regular/64x64/pinterest.png)
![Share on Linkedin linkedin](https://www.thesecuritybuddy.com/wordpress/bdr/plugins/social-media-feather/synved-social/image/social/regular/64x64/linkedin.png)
![Share by email mail](https://www.thesecuritybuddy.com/wordpress/bdr/plugins/social-media-feather/synved-social/image/social/regular/64x64/mail.png)
0 Comments