Skip to content
DevPlainly
Security

PGP Explained: How Signatures and Encryption Work

What PGP is and why it's still useful: how signing and encryption work, tested step by step with GPG, and how Cicada 3301 used it so nobody could fake them.

Published
Reading time
8 min read
Contents
  1. PGP, OpenPGP and GPG
  2. The idea: two keys that work as a pair
  3. A famous example: Cicada 3301
  4. Try it yourself: sign, verify and catch a fake
  5. 1. Create a key pair
  6. 2. Share the public key
  7. 3. Sign a message
  8. 4. Verify it
  9. 5. Change one character
  10. The warning: who does the key belong to?
  11. Encrypt a message
  12. Where PGP is used today
  13. Limitations worth knowing
  14. FAQ
  15. Is PGP still secure?
  16. What's the difference between PGP and GPG?
  17. Can a PGP signature be faked?
  18. What happens if I lose my private key?
  19. Is a short key ID like 7A35090F enough to identify a key?
  20. Further reading

PGP lets you do two things with a message or a file: prove who wrote it and make sure only the right person can read it. It's over thirty years old, and it still protects Linux packages, software downloads, Git commits and private emails every day.

This guide explains how PGP works with one simple picture, shows the famous case of Cicada 3301, and walks through every step with GPG: creating keys, signing, catching a forged message, and encrypting. Every command and output below was run with GnuPG 2.4.

Nil's note

I learned what PGP was from a video about the Cicada 3301 mystery. The idea that an anonymous group could prove every message was theirs got me hooked, so I read up on how it works. Today I use it every day to sign my Git commits.

PGP, OpenPGP and GPG

The names get mixed up, so first:

  • PGP ("Pretty Good Privacy") is the original program, from 1991.
  • OpenPGP is the open standard that grew out of it. Any program can implement it, and they all understand each other.
  • GPG (GnuPG) is the free implementation most people use. It comes with most Linux systems and Git for Windows.

In everyday use, "PGP" means the whole idea, and gpg is the command you type.

The idea: two keys that work as a pair

Everyone using PGP has two keys that only work together:

  • A private key, which you keep secret on your computer, protected by a passphrase.
  • A public key, which you give to everyone: on your website, on a key server, in your email signature.

The pair does two different jobs:

JobYou useThey useLike
Signing: prove a message is yours and unchangedYour private key, to signYour public key, to checkA wax seal only your ring can make, that anyone can recognize
Encrypting: only one person can read itTheir public key, to lockTheir private key, to unlockA mailbox anyone can drop letters into, but only the owner can open

The math behind it makes one thing practically impossible: making a valid signature, or opening an encrypted message, without the private key. Having the public key doesn't help.

A famous example: Cicada 3301

In January 2012, an anonymous group calling itself Cicada 3301 started posting a series of puzzles online, mixing cryptography, books and hidden messages. Its members were never identified.

Fame brought imitators: soon there were fake Cicada puzzles and messages everywhere. The group's answer was PGP. It announced that it would sign every message with one key, ID 7A35090F, published on public key servers. From then on, anyone could check a message in seconds:

  • Valid signature from that key: the message really came from Cicada.
  • No signature, or a signature from any other key: fake, however convincing it looked.

The impostors could copy the style, the images and the wording. They couldn't copy the signature, because that needs the private key, and nobody else had it. An anonymous group with no names and no faces had an identity nobody could steal.

Try it yourself: sign, verify and catch a fake

These steps use two people, Alice and Bob. You can follow along on Linux, macOS (with GnuPG installed through Homebrew) or Windows (Gpg4win, or the GPG that comes with Git Bash).

1. Create a key pair

gpg --quick-generate-key "Alice <alice@example.com>" future-default default never

GPG asks for a passphrase and creates the pair. future-default picks modern algorithms (Ed25519 for signing, Curve25519 for encryption) and never means it doesn't expire. List it:

pub   ed25519 2026-11-13 [SC]
      EC9EFABAF330C393831198259F26413DF3AE4DA3
uid           [ultimate] Alice <alice@example.com>
sub   cv25519 2026-11-13 [E]

The long hexadecimal string is the key's fingerprint. The key ID is just its last characters: F3AE4DA3 (short) or 9F26413DF3AE4DA3 (long). Cicada's 7A35090F was a short key ID like this one.

GPG also saves a revocation certificate in ~/.gnupg/openpgp-revocs.d/: a file that tells the world "this key is no longer valid". Keep a copy somewhere safe in case the key is ever lost or stolen.

2. Share the public key

gpg --armor --export alice@example.com > alice.asc   # Alice publishes this file
gpg --import alice.asc                               # Bob imports it

3. Sign a message

gpg --clearsign message.txt

The result, message.txt.asc, is the readable text wrapped in a signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

The next puzzle starts at 00:00 UTC.
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQTsnvq68zDDk4MRmCWfJkE9865NowUCavaAJQAKCRCfJkE9865N
...

4. Verify it

Bob checks the message with Alice's public key:

$ gpg --verify message.txt.asc
gpg: Signature made Fri Nov 13 03:12:37 2026 UTC
gpg:                using EDDSA key EC9EFABAF330C393831198259F26413DF3AE4DA3
gpg: Good signature from "Alice <alice@example.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.

Good signature means the message is exactly what the holder of that key signed. The warning is important, and we'll come back to it.

5. Change one character

Someone edits the message and changes 00:00 to 01:00. The signature is copied over unchanged:

$ gpg --verify tampered.asc
gpg: BAD signature from "Alice <alice@example.com>" [unknown]

One character was enough. The signature covers every byte of the message, so any change, however small, breaks it, and gpg exits with an error code you can check in scripts.

The warning: who does the key belong to?

A good signature proves the message came from that key. It doesn't prove the key belongs to the person whose name is on it: anyone can create a key called "Alice". That's what the warning means.

The fix is to check the key's fingerprint through a second channel you already trust: their website, a video call, a business card, or in person. Cicada did exactly this by publishing its key ID up front, so solvers could compare it with every message that claimed to come from Cicada. Once you've confirmed a fingerprint, you can sign the key yourself (gpg --sign-key) and the warning goes away.

Encrypt a message

To send Bob something only he can read, Alice encrypts it with Bob's public key:

gpg --armor --encrypt --recipient bob@example.com secret.txt

The result is unreadable to everyone but Bob, including Alice. When we tried to decrypt it with Alice's keys, GPG refused:

gpg: decryption failed: No secret key

Bob decrypts it with his private key:

$ gpg --decrypt secret.txt.asc
Meet at the usual place.

To keep a copy you can read yourself, add your own key as a second recipient: --recipient bob@example.com --recipient alice@example.com.

Where PGP is used today

  • Verifying downloads. Linux distributions, the Tor Browser and many open-source projects publish a signature next to each download, so you can check the file wasn't tampered with on the way.

  • Software updates. Package managers like apt check repository signatures before installing anything; that's why adding a third-party repository asks for its key.

  • Signed Git commits. Git can sign each commit, and GitHub and GitLab show a "Verified" badge on them:

    git config user.signingkey EC9EFABAF330C393831198259F26413DF3AE4DA3
    git commit -S -m "Signed with PGP"
    git verify-commit HEAD   # gpg: Good signature from "Alice <alice@example.com>"
    

    Git can also sign with an SSH key instead, which is simpler if you already have one; see SSH keys explained. Check git config gpg.format: it's openpgp for GPG and ssh for SSH keys.

  • Email. Thunderbird supports OpenPGP out of the box, and Proton Mail uses it behind the scenes.

Limitations worth knowing

  • Key management is the hard part. Losing your private key means losing access to everything encrypted to it. Losing control of it means someone else can sign as you, until you publish the revocation certificate.
  • Encrypted email still leaks metadata. Who wrote to whom, when and the subject line aren't encrypted, only the body.
  • There are simpler tools for some jobs. For private chat, Signal is easier and protects past messages if a key leaks later. For encrypting files, age has a much simpler interface. For signing, SSH keys and Sigstore are popular in software projects.

PGP's strength is that it's a standard everyone understands, and that for signatures it works anywhere: a file, an email, a commit or a forum post.

FAQ

Is PGP still secure?

Yes, with modern keys. Ed25519 and Curve25519 keys, the defaults above, or RSA keys of 3072 bits or more are considered secure. The weak spot is almost always the person: a stolen private key, a weak passphrase or an unchecked fingerprint.

What's the difference between PGP and GPG?

PGP is the original program and the name people use for the whole idea. GPG (GnuPG) is the free, open-source program that implements the OpenPGP standard. Files from one work with the other.

Can a PGP signature be faked?

Not without the private key. That's the whole point, and the reason Cicada 3301's imitators couldn't pass as the real thing. What can be faked is a key with someone else's name on it, which is why you check the fingerprint.

What happens if I lose my private key?

You can't decrypt anything encrypted to it, and you can't sign with it again. Publish your revocation certificate so people stop using the old public key, then create a new pair. Back up your private key and revocation certificate somewhere offline.

Is a short key ID like 7A35090F enough to identify a key?

It was common in 2012, but 8 characters are short enough to fake: people have created keys with matching short IDs on purpose. Today, compare the full fingerprint, or at least the 16-character long ID.

Further reading

Written by Nil Martinez

Developer · DAM & DAW student

Developer studying multiplatform (DAM) and web (DAW) application development. I work every day with TypeScript, Angular, React, Java, Python, FastAPI, MySQL and Docker on Kubuntu, and I write about the tools I actually use.

How I test and write each guideGitHub

Keep reading