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

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

To encrypt a PGP message, you use the recipient's public key; to decrypt one, you use your matching private key and its passphrase. This guide walks through both steps in the browser, then explains common errors, GPG compatibility, and when to use the PGP encryption tool or the PGP decrypt page.

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 PGP encryption tool (or the Encrypt tab on the homepage).

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. If a mail or chat app added extra spaces or broke lines, paste it as plain text and restore the header and footer exactly.

2. Open the PGP decrypt page (or the Decrypt tab on the homepage). 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. There is no recovery if the passphrase is wrong: the site never sees it and cannot reset it.

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. When you are finished, clear the private key and passphrase from the form.

Which key decrypts a PGP message?

A PGP message is locked to one or more public keys. Only the matching private key (and its passphrase) can unlock it. The sender's public key cannot decrypt the message, and your own public key cannot decrypt a message that was encrypted only to someone else.

If decryption fails with an error about a missing key, you almost always have the wrong private key, or the sender used an old or different public key than the one you think they used. Confirm which public key they encrypted to, then import the private key that belongs to that public key.

Can I decrypt a GPG message in the browser?

Yes. GnuPG (GPG), Kleopatra, Thunderbird, and this site all speak OpenPGP, so a message created with GPG can be decrypted here if you paste the ASCII armor block and the matching private key. Ciphertext from OnlinePGP can also be decrypted in GPG.

If you have a .gpg, .pgp, or .asc file instead of a text block, use the file decryption tool rather than the message form.

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:

1. Confirm the sender encrypted the message using your current public key, not an older or revoked key.

2. Verify you imported the matching private key, not a public key and not a different key pair.

3. Recheck the passphrase for typos or Caps Lock. A single wrong character will fail, and there is no reset.

4. Check that the ciphertext was not truncated and that the BEGIN and END lines are intact. Re-copy the block as plain text if a mail client wrapped or escaped it.

5. If the sender used a newer OpenPGP v6-only key or algorithm, an older v4 client may not support it. Try decrypting in a current GnuPG install as a second check.

Still stuck? The PGP decrypt page shows a status message under the form that often names the problem (missing key, bad passphrase, or unreadable armor).

Text Messages vs. Binary Files

The PGP encryption tool and PGP decrypt page are designed for text messages. If you need to encrypt or decrypt photos, PDFs, or archives, use the PGP file tool, which runs in the browser, or desktop software such as GnuPG 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. Use the PGP file tool in your browser, or desktop software such as GnuPG, to encrypt PDFs, photos, and other files. The message tool on this site is for text.

Why can't I decrypt a PGP message with a public key?

A public key only encrypts (or verifies a signature). To decrypt, you need the matching private key and its passphrase. If you only have a public key, ask the intended recipient to decrypt the message, or check that you imported the correct private key.

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. Encrypt or decrypt a message 100% locally in your browser.

Open the PGP encryption tool Open PGP Decrypt