How to Encrypt and Decrypt a Message with PGP Step by Step

A document beside a locked capsule, illustrating PGP encryption and decryption

Before You Begin

To exchange encrypted messages with someone using PGP, you need two things: the recipient's public key (to encrypt messages to them) and your own private key plus passphrase (to decrypt messages they send to you).

If you do not have a key pair yet, generate a PGP key online first and share your public key with your contact. Before trusting a new contact's public key for sensitive topics, always verify their key fingerprint.

Part 1: How to Encrypt a Message

1. Obtain the recipient's ASCII-armored public key. It starts with -----BEGIN PGP PUBLIC KEY BLOCK----- and ends with -----END PGP PUBLIC KEY BLOCK-----.

2. Open the Encrypt tab on OnlinePGP.com.

3. Paste the recipient's public key into the field labeled Enter the recipient's public key here (or click IMPORT PUBLIC KEY to load a .txt file).

4. Type or paste your confidential message into the Enter the text to be encrypted here box and click ENCRYPT TEXT.

5. Copy the resulting -----BEGIN PGP MESSAGE----- block and send it to your recipient over email, chat, or any other channel. Even if intercepted, the ciphertext is unreadable without the recipient's private key.

Two browser windows connected by a padlock and key, illustrating encrypting in one place and decrypting in another

Encrypting to Yourself (Keeping a Readable Copy)

A common surprise for newcomers is that once you encrypt a message to someone else's public key, you cannot decrypt it yourself. If you want to keep a readable copy of what you sent, desktop clients like Thunderbird and GnuPG can encrypt a message to both the recipient's key and your own public key at the same time.

Note that the current web interface on OnlinePGP.com encrypts to the single public key pasted into the field. If you need an encrypted archive copy for yourself, you would either save the plaintext locally in an encrypted folder or run a second encryption pass with your own public key.

Part 2: How to Decrypt a Message

1. Copy the entire encrypted message block, including the -----BEGIN PGP MESSAGE----- and -----END PGP MESSAGE----- lines.

2. In the Decrypt tab of our PGP tool, paste your private key into Enter the private key here (or click IMPORT PRIVATE KEY).

3. Enter the passphrase that protects your private key in Enter the passphrase here.

4. Paste the encrypted message into Enter the text to be decoded here and click DECRYPT TEXT. Your original plaintext message will appear in the output box.

ASCII Armor Pitfalls to Watch Out For

Because PGP messages are sent as plain text, formatting changes introduced by email clients or chat apps can break decryption. Watch out for missing header or footer lines (leaving out even a single hyphen in -----BEGIN PGP MESSAGE----- makes the block unreadable), rich-text line wrapping, invisible HTML tags, and smart quotes.

Always paste PGP blocks in plain-text mode whenever your email client or chat app supports it.

Troubleshooting Common Decryption Errors

If decryption fails, work through this checklist: first, confirm the sender encrypted the message using your current public key and not an older or revoked key. Second, verify you are using the matching private key. Third, double-check your passphrase for typos or Caps Lock. Fourth, check that the ciphertext was not truncated. Finally, if the sender used a newer OpenPGP v6-only key or algorithm, an older v4 client may not support it.

Text Messages vs. Binary Files

Browser-based tools like OnlinePGP.com are designed for text messages. If you need to encrypt photos, PDFs, or large archives, use desktop software such as GnuPG (gpg --encrypt --recipient user@example.com file.pdf), which can encrypt arbitrary binary files directly on your computer.

Next, learn how digital signatures prove who sent a message in What Is PGP and How Does It Work?, avoid common pitfalls in Common PGP Mistakes, or set up daily encrypted email in PGP for Email.

Frequently Asked Questions

Whose key do I use to encrypt a message?

Always use the recipient's public key—never your own public key (unless you are encrypting a note to yourself).

Why can't I decrypt a message I just encrypted?

Because it was encrypted with the recipient's public key, only the recipient's private key can decrypt it.

Can I encrypt attachments or files with PGP?

Yes, desktop tools like GnuPG can encrypt arbitrary binary files, while browser tools like OnlinePGP.com focus on text messages.

Is it safe to send PGP ciphertext over ordinary email or chat?

Yes. The entire purpose of PGP is that the encrypted message block can travel over untrusted channels without revealing its contents.

Try It Now with OnlinePGP.com

Put this guide into practice right away. Generate a PGP key pair, encrypt a message, or verify a signature 100% locally in your browser.

Open the Online PGP Tool