Encyrpt/Decrypt Files/Messages with GPG

Let’s say that you have a very confidential message or file that you want to share with someone and you absolutely don’t want anyone else to be able to see it. Most people would just share the message via email or some other communication tool, but this isn’t necessarily secure, especially since the tool provider, like Gmail, could access your email communications. When you want to be 100% sure that only your recipient can view your message, the best practice is to encrypt/decrypt it using GPG.

Encryption Variations

Pretty Good Privacy (PGP) is a proprietary encryption program that provides cryptographic privacy and authentication for data communication.

OpenPGP is a non-proprietary, open-source version of PGP.

GnuPG (Gnu Privacy Guard / GPG) is a non-proprietary, open-source version of OpenPGP.

GpgFrontend

This post will show you how to share secret messages with a friend by encyrpting/decrypting them using GPG. There are many tools that can encrypt/decrypt messages using GPG, including command line tools. I will use GpgFrontend because it appears to be the easiest for the general public to use. For this tutorial, I will use Windows.

1. Download the GpgFrontend

Both you and your friend will need to perform this step.

You can download the Windows installer or the portable version that doesn’t require installation. For simplicity, I will just download the portable version.

  1. Download the portable version from GpgFrontend’s latest releases, labeled GpgFrontend-*******-windows-x86_64-portable.zip.
  2. Extract the contents of the downloaded ZIP file.
  3. Run GpgFrontend.exe from the extracted Program/bin directory.

2. Generate a Key Pair

Your friend will need to perform this step.

Open GpgFrontend

Click on “Manage Keys”.

    Click “New keypair”.

      Fill in your details, such as name and email, and choose your desired key type and size. You can also add a comment if you wish. Set an expiration date for the key, or choose ‘Never Expire’ if you prefer. Optionally, create a passphrase for added security. I will click the Non Pass Phrase checkbox for simplicity. Once all details are filled in, click ‘OK’ to generate your key pair. You will then see your key listed in the KeyPair Management window.

        3. Share Public Key

        Your friend will need to perform this step.

        In the KeyPair Management window, select the key you want to export, right-click, and click “Show Key Details”.

        Click the “Operations” tab, then click the “Export Public Key” button.

        Save the public key somewhere on your computer. For me, the filename generated was David[email protected]_pub.asc. The “pub” stands for “public” because this is your public key that you can share with other people. If you open the public key file, it will look something like this.

        Your friend should send you this file so that you can use it to encrypt your message.

        4. Import Public Key

        You will need to perform this step.

        Click “Import Key” -> “File” and browse to the public key file your friend shared with you.

        Click the OK button to confirm importing the key.

        5. Encrypt a Message

        You will need to perform this step.

        Write a message in the main text area of GpgFrontend.

        Check the public key in the list of keys in the Key Toolbox pane. To do this, click in the leftmost column of the key you want to use, outlined in red in the screenshot below.

        Click the “Encrypt” button. You will see that your plaintext message was converted to a PGP message.

        6. Share the Encyrpted Message

        You will need to perform this step.

        Copy the encrypted message and share it with your friend, e.g. via email.

        7. Decrypt the Encrypted Message

        Your friend will need to perform this step.

        Copy the encrypted message into GpgFrontend’s main text area.

        Click the “Decrypt” button. You’ll see the encrypted message get converted to plain text.

        With GPG, you can do many other things as well, including

        Learn more