GPG or the GNU Privacy Guard is a free and open source software that implements OpenPGP public-key cryptography message format (RFC4880). You can use GPG to encrypt, decrypt, sign and verify files or emails. To use GPG, you need to generate the public-key/private-key pairs in your computer by running this command, and choose the default option
The application will ask you to enter your ID and passphrase, make sure you choose a strong passphrase to guarantee the safety and security of your keys.
Encrypting and Decrypting Files
You can use GPG to encrypt files, it can be only decrypted by those who have your public-key. The command that can be used to encrypt file is :
gpg --out encrypted_file.txt --encrypt original_file.txt
Run this command to decrypt. Files encrypted with private key can only be decrypted with public key and vice-versa.
gpg --out decrypted.txt --decrypt encrypted_file.txt
Signing Email or body of texts
Alternatively, you can chose to sign emails/texts instead of encrypting them. Signing files is a way to ensure that the message/texts/emails are from the right sender and its content has not been tempered with. You can run this command to sign email or texts :
gpg --clearsign original_text.txt
This will produce a signature file which content the original text with PGP signature embedded at the bottom of the message.
To verify it (assuming you have the public key), you need to run this command:
gpg --verify original_text.txt.asc