PGP

PGP
PGP

PGP (Pretty Good Privacy) has been around for a long time. PGP is a system that allows you to encrypt a message using a key pair. A key pair consists of a public key and a private key. The public and private key pair are created at the same time and are permanently linked; one can not work without the other.

The basics of PGP are that the private key has a passphrase on it that only the creator knows. When you encrypt a message with PGP you encrypt it with your private key and a public key you specify, be that your public key or someone else’s public key. This makes it so the PGP encrypted message can only be decrypted using the public key you specified.

Here is a step-by-step example of using PGP.

Setup

For this example I will use an online PGP Tool.

First we need to generate our key pair to get our public and private key.

  • Fill in the options and click Generate keys
PGP key pair options
  • Download the public and private key.
My example public and private keys

Below is my full PGP public key for this example.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: Keybase OpenPGP v2.0.76
Comment: https://keybase.io/crypto

xo0EZSHBoAEEAOgwPyzB0SK3qTcMm4qAdPy5v3uB+pEydKIypNMW+aDPc4ybYAYy
lPgKXmLqAEFE7QkE6zkvOJwUAoqZLOHinAD41f66pxZfEGCcdfPF5X7PPJHyr5/y
znNZLs28O54yZ2lLbsecTR+znyADMK3oebSDnuiJURlqC8L0Y8xekwm9ABEBAAHN
GW15IG5hbWUgPGVtYWlsQGdtYWlsLmNvbT7CugQTAQoAJAUCZSHBoAIbLwMLCQcD
FQoIAh4BAheAAxYCAQIZAQUJAAAAAAAKCRAZDnvqP9lqifE8A/4ytKWOSQJLSVzY
p2K0gtSLmFOfgD+kaMQ+CdtUEBbU/V6UoMu8w1/eRS9XMX4eDTY5n+paT0r6+Vis
ej9tFhTR1O0iZ+6Bose/MBIiSElZrw38rqmlh3tJd7iL1J3/THTM58+hjj2Ld4QZ
oomr1U4ORvLRF8vUNpTlxrOKRcyiz86NBGUhwaABBADiTMFd/AcihKHreVmHpxxW
buZHdtyj7sk6j7eEWAv40LnnhtZWASiW0BR07DRQzFMQmOrHaSqwdI5Ey/B/XBIl
el5+fIp/9/wEuAL7i3/fc8ugGJoEMuW4NLSNLjzHHasd8b9QT4mxD/F96JLx1ewF
masTU56csW2UqJnrUA5LTwARAQAB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B9N7m6ZPBvpiv
=vnvb
-----END PGP PUBLIC KEY BLOCK-----
Code language: plaintext (plaintext)

Encrypting

Now lets encrypt a message.

  • Click on the Sign tab.
  • Upload your private key and enter your passphrase.
  • Enter your message and click Sign the message

We have now encrypted the message with your key pair. The encrypted message can only be decrypted using your PGP public key from your key pair.

Here is the encrypted message I created with my example key pair.

-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v2.0.76
Comment: https://keybase.io/crypto

yMALAnicO8LLzMDF6Mf683i+e6gX42nRUoZUxUOSIRmZxQpAlJtaXJyYnnpoDgsD
IxcDGysTSJKBi1MApuP3ZOb/oV09L4NVVp2UXf7z356ZuZ1vDqrfTZduP31dkFfE
LepLromYgsHTdWysIV5tYfe/TF9wdIY5y1zmrdfTZnxh0HoZ6cxbyzvrCiuDTtGT
fzd/bZ1lU3DJ44KSQ+1a9rvWgu9nJp9f9NWxUUOB57pvSlyQtMifj7m1cU4P5vgE
ZJtlf1Vq31YAADviUq0=
=4LQP
-----END PGP MESSAGE-----Code language: plaintext (plaintext)

Decrypting

Now let’s decrypt the encrypted message.

  • Click on the Verify tab.
  • Enter the public key the message was encrypted with. In this example it is my public key.
  • Enter the encrypted signed message
  • Click on Verify signature to decrypt the message.

That’s all it takes to encrypt and decrypt a message with PGP.

This only covers the simplest form of PGP. You can do more advanced PGP encryption if you have the recipient’s public key which would make it so the message can only be decrypted by the recipient using your public key and their private key rather than just your public key.

If you want to read more about PGP here is RFC 4880 about PGP.

One response to “PGP

Leave a comment

Your email address will not be published. Required fields are marked *