How to Use PGP to Encrypt a Message
How to use PGP comes down to one habit: lock the message on your own computer, to the other person's key, before it goes anywhere. A public key is a padlock they have hung where anyone can see it. You can snap it shut on a letter. Only they hold the key that opens it. A signature is a different object, a wax seal, and it answers a different question: who sent this, and did anyone change it. Until the text is locked on your machine, whoever is carrying it has already had a chance to read it.
A lock and a seal
PGP does two jobs, and mixing them up is how people think they have sent a private message when they have only stamped it. Encryption puts the text in a form that one private key can open. A signature does not hide anything. It sticks a checkable mark on the text, so a change of one character makes the mark fail, and the mark can be tied to a specific key.
The GNU Privacy Handbook, the manual for GnuPG, states the lock in a single line: only the person who holds the private key can recover a document encrypted with the matching public key.
In other words, only the person who holds the private key can recover a document encrypted using the associated public key.
You will see both jobs in the same block of text. A signed and encrypted message is locked and sealed. A message that is only signed can be read by anyone who copies it, seal and all. The PGP verification guide is entirely about the seal: how to check that a list of addresses was signed by the key you think it was. This page is the lock. The programs are the same ones. Kleopatra on Windows, GPG Suite on a Mac, GnuPG on Linux and on Tails. If you already installed one of them to check a signature, you do not install a second tool to write a message.
Make your own key
You need a pair before you can receive a reply. The public half is the padlock you hand out. The private half stays on your computer, and GnuPG wraps it in a passphrase so a copied file is not immediately usable. Lose the private key, or forget the passphrase, and every message locked to you is gone. There is no recovery desk.
In Kleopatra, create a new OpenPGP key pair and write the passphrase down somewhere that is not the same machine, if you write it down at all. On the command line the same step is gpg --full-generate-key. A name and an email are labels so you can find the key later. On a market they are often a nickname and a throwaway address. The labels are not what makes the key yours. The fingerprint is.
Give people the public half only. gpg --armor --export you@example.com prints a block that starts with -----BEGIN PGP PUBLIC KEY BLOCK-----. That block is safe to paste on a profile, a forum, or a market's contact page. The block that says PRIVATE KEY is the opposite. It never goes in a message, a paste site, or a screenshot. Exporting it "as a backup" onto a cloud drive is how private keys end up in other people's hands, and then the lock is theirs too.
Lock a message to someone
You lock to their public key, not to yours. A message encrypted only to yourself is a diary. They cannot open it. GnuPG will also refuse to let you read a message you encrypted only to them, which surprises people the first time. If you need a copy you can still open, add your own key as a second recipient. The handbook is explicit: you cannot decrypt a document you encrypted unless your own public key was in the recipient list.
- Get their public key as a block, from a page you have a reason to trust, and save it. Import it with
gpg --import their-key.asc, or in Kleopatra with the import command. Importing does not mean you believe the name on it. That check is the next section. - Write the message in a plain file, not in the website's text box. Once it is typed into someone else's form, they already have it.
- Encrypt it to their key.
gpg --encrypt --armor --recipient "Their Name" message.txtwritesmessage.txt.asc, a block from-----BEGIN PGP MESSAGE-----to the matching END line. In Kleopatra's Notepad, the same window used to check a signature, choose Encrypt and pick their key. Armor means the result is text you can paste, rather than a binary file a form will mangle. - Paste the whole block, including the BEGIN and END lines. A missing line does not "mostly" decrypt.
Add --sign before --encrypt when they need to know it was you. The signature uses your private key. The lock uses theirs. The order in the command is sign, then encrypt, so the seal is inside the lock and a stranger cannot read who sealed it either.
Read the reply
A reply locked to you opens with your private key and the passphrase. Save their block as a file and run gpg --decrypt reply.asc. Kleopatra does it from the same Notepad with Decrypt/Verify, which is the button the verification guide already uses for signatures. If the message was also signed, the output names the signing key. A good signature means the text matches that key. It still means nothing if you never checked whose key that is.
Two failures look similar and are not. "No secret key" means the message was locked to some other key, not yours. You cannot read it, and asking them to send it again only helps if they lock it to the public key you actually published. A passphrase GnuPG keeps rejecting means the private key is present and the passphrase is wrong, or you are typing the passphrase of a different key. Paste the block again before you decide the message itself is broken.
Know the key is theirs
A name on a key is a label the creator typed. Anyone can make a key whose name is a market, a vendor, or you, and GnuPG will import it without complaint. The check that sorts the real key from the copy is the fingerprint, the long hex string gpg --fingerprint prints. For the keys in ordinary use that string is 40 characters. Compare it, character for character, with a fingerprint you got from a second place that does not depend on the first.
The whole attack this defeats, a fake key and a fake signed message published together so the software says "good signature," is written out in the verification guide. The same attack works on a conversation. A stranger sends you a public key inside the chat, you lock your reply to it, and you have handed the letter to them. Fetch the key from somewhere you already had, a profile you reached by a verified address, a fingerprint they read out in a voice you know, a second forum account that has carried the same fingerprint for months. A key that arrives in the same message as the question is not a source. It is the thing you are trying to check.
Where the lock fails
The mathematics holds. The failures are all earlier, at the moment the readable text still exists on a machine you do not control.
- A website offers to encrypt for you. To lock the message, that site has to see the original. It can store the original and hand the vendor a properly locked copy, so both of you see a PGP block and think the text was private. On a market this is the checkbox next to a shipping address. Why that checkbox is the leak, and what was recovered from Silk Road's servers because people skipped it, is in the buyer-safety guide. The rule is the same off a market: lock it locally, then paste.
- The key and the address came from the same page. A cloned page can publish a cloned key. The fingerprint comparison has to use a second source.
- The private key left the computer. A backup on a disk you control is a backup. A private key in email, in a chat, or in a "secure note" site is a copy someone else can use to open your mail and to sign as you.
- You locked it to the wrong key, including your own. Read the recipient line before you send. If their name is not on it, they cannot open it, and if only your name is on it, you have written a diary.
After the block is pasted, delete the plain file. The locked copy is the one that can sit in a sent folder. The text file you typed is the one that undoes the hour you just spent, the next time that disk is copied.
Common questions about PGP encryption
Is PGP the same as GPG?
People use the names for the same job. PGP is the original program, and the method is now an open standard called OpenPGP. GPG, short for GnuPG, is the free program almost everyone actually runs, including the Kleopatra window on Windows. A key made in one of them opens in the others. When a site says "PGP key," it means an OpenPGP key, and GnuPG is what you use to work with it.
Do I need to sign a message if I already encrypted it?
Encryption and a signature do different jobs, and you usually want both. Encryption means only the recipient can read it. A signature means they can see that it came from your key and that nobody changed a character. A locked message with no signature can be read by the right person and still be from anyone. Sign it as well when it matters who sent it.
What if their key is expired?
An expired key is one its owner marked with an end date. Do not keep locking new messages to it. Ask for a current key and check that key's fingerprint the same way, against a copy that did not come from the same page as the address. A message you locked before the expiry can still be opened by them. The expiry stops new mail, it does not erase the old key.
Can I use the same key to check a market address?
Yes. One key pair both locks messages and makes signatures. Checking a market is the signature half: you confirm that a list of addresses was signed by the operator's key. That procedure, including how a fake key can still say "good signature," is the PGP verification guide. This page is the other half, locking a message so only one person can read it.
rdark