Join our Newsletter — 33% off our NHI Course
Home› Guides› PGP and GPG for Beginners: Encrypting and Signing…
Guide Email & Communications Security

PGP and GPG for Beginners: Encrypting and Signing Files and Email

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 2 December 2026 12 min read
On this page

PGP is a way to lock and sign files and email, so only the right person can read them.

This guide is for anyone who has seen "PGP key" or "GPG signature" on a download page or in a profile and wondered what it means. You do not need to code. If you install software, the people who make it may use these signatures to show their files are genuine.

In short

  • PGP is an open standard, called OpenPGP, and GPG (GnuPG) is a free program that follows it.
  • Each person has a key pair: a public key they share and a private key they keep secret.
  • Others use your public key to lock messages to you and to check your signatures.
  • Guard the private key with a strong passphrase, check fingerprints, and make a way to cancel the key if it is lost.

What you will learn

  • Explain the difference between a public key and a private key.
  • Describe what encrypting and signing each do.
  • Check a fingerprint before you trust someone's key.
  • Spot why a leaked signing key is serious for software makers.
Two matching keys (key pair)
a public key you can share and a private key only you keep.
Proof of who sent it (digital signature)
a mark made with a private key that shows who signed a file and that it was not changed.
Key ID card (fingerprint)
a long code that identifies one exact key, used to check you have the right one.

What is PGP?

Think of a padlock you hand out and the only key you keep. Anyone can snap your open padlock shut on a box for you. Only your key opens it again.

PGP works the same way. Your public key is the padlock, which you can share. Your private key is the one key that opens it, so you keep it secret [2][4].

PGP is now an open standard called OpenPGP. It covers encryption (scrambling data so only the right person can read it), digital signatures and key management [1]. GnuPG, often called GPG, is a free program that follows this standard and lets you encrypt and sign data [3].

Where the comparison stops working: a padlock cannot sign anything. With PGP, your private key can also make a signature. Others check it with your public key, like checking a wax seal.

Why does it matter?

PGP keeps private messages private and helps people check that files are genuine. A careless private key can undo both.

If you download software

What could happen: you install a tampered file from a copy site, and nothing tells you it changed.

Check this: does the official site publish a signature or checksum for the download?

Next: Checksums for Beginners

If you send private email

What could happen: you lock a message with a fake key that a stranger put online in your contact's name.

Check this: compare the key's fingerprint with your contact by phone or in person.

Next: Email Encryption for Beginners

If you write or publish code

What could happen: a signing key stored in a build system leaks, and someone could sign files in your name.

Check this: who and what can use your signing keys, and where are they stored?

Next: Non-Human Identities for Beginners

What does it look like?

Here is a made-up summary of a public key, like one you might see on a profile or download page.

Example only. All values are made up.

Public key for: Example Maker <[email protected]>   (1)
Fingerprint: 0000 FAKE 0000 FAKE 0000  0000 FAKE 0000 FAKE 0000   (2)
Created:     2026-01-01                            (3)
Expires:     2028-01-01                            (4)
Signed by:   2 other EXAMPLE keys                  (5)
  1. In a real file, this line would contain the name and email the key belongs to.
  2. The fingerprint. Compare all of it, not just the last few characters.
  3. When the key was made.
  4. Keys can be set to expire, so a forgotten key does not stay in use.
  5. Other people who have vouched for this key. This is the "web of trust".

Why this is risky: anyone can make a key with any name and email on it. A name alone proves nothing.

The safer way: get the fingerprint from the person or an official page you trust, and check it matches in full.

How does it work?

Here is what happens when Ana sends a locked, signed file to Ben.

  1. Each person makes a key pair. They keep the private key and share the public key, sometimes through a public directory called a keyserver [4].
  2. Ana checks Ben's key. She compares its full fingerprint with Ben. Checking the fingerprint in person is how you know the key really is his [5][4].
  3. Ana locks the file with Ben's public key. Only the person with the matching private key can open it [6].
  4. Ana signs it with her private key. Ben checks the signature with Ana's public key. That shows it came from Ana and was not changed on the way [4].
  5. Ben opens the file with his private key. A passphrase protects his private key, so a stolen copy is harder to use [2].
Diagram titled Locking and signing with PGP. Four boxes in a row joined by arrows. Box 1, Ana's file: a private document. Box 2, Lock: with Ben's public key. Box 3, Sign: with Ana's private key. Box 4, Ben: opens it with his private key and checks the signature with Ana's public key. A note underneath says public keys can be shared, private keys stay secret, and you should check fingerprints before trusting a key.
Figure 1. Public keys lock and check; private keys open and sign.

The web of trust

Checking every fingerprint yourself is slow. PGP lets people vouch for keys by signing them. If you trust someone to check keys carefully, you can accept keys they have signed [5]. This is called the web of trust.

Signing downloads and code

Some software makers sign their downloads. For example, some sign a list of checksums. A checksum is a short code that changes if a file changes. Customers use the signed list to check their downloads [7]. Code sites also support signing changes. On GitHub, you can sign commits (saved changes to code) with GPG, SSH or S/MIME. This gives others confidence about where a change came from [8].

Diagram titled Checking a signed download. Four boxes in a row joined by arrows. Box 1, Get the file and its signature from the official site. Box 2, Get the maker's public key and check its fingerprint. Box 3, Check the signature with GPG or your software tool. Box 4, Good signature: the file matches what the key holder signed. A note underneath says a bad or missing signature means stop and do not install.
Figure 2. The steps behind checking that a download is genuine.

When a signing key leaks

Signing keys used by build systems are secrets held by software, not people. That makes them a kind of non-human identity (an identity used by software, with its own access). In 2021, HashiCorp said the private GPG key it used to sign checksums for its product downloads was exposed. HashiCorp linked the exposure to a security event at Codecov, a third-party tool [7].

HashiCorp rotated the key, revoked the old one, published a new key and re-signed its releases. It said its investigation had not found evidence the exposed key was misused [7]. Our analysis is in HashiCorp GPG Key Exposure 2021.

A worked example

This story is made up to show the idea.

Reza Grover volunteers on a small free app for planning allotments. Users have started asking how they can tell the download is genuine.

Reza installs GPG and makes a key pair. He picks a long passphrase and sets the key to expire in two years. Straight away, he makes a revocation certificate (a file that tells people to stop trusting a key). He prints it and keeps it in a locked drawer, away from his laptop.

He publishes his key's full fingerprint on the project's website. At a meet-up, another volunteer compares fingerprints with him and signs his key.

From the next release, Reza signs the list of checksums for each download. The website explains, in two lines, how users can check the signature. He also turns on commit signing, so his code changes show as verified on the code site.

The project's automatic build system also needs to sign test builds. Reza gives it a separate key that can only sign, stored in the build system's secret store. He notes who owns it and when it expires.

A year later, a volunteer's laptop is stolen. Because the build key is separate, it is not affected. Reza still checks the build logs and finds nothing unusual in the records available to him.

Reza learned that the maths is the easy part. The real work is guarding private keys and making it simple for others to check.

Myths and mistakes

What people thinkWhat is true
A key with my contact's name on it must be theirs.Anyone can make a key with any name. Check the full fingerprint with the person [4].
PGP hides everything about an email.The subject line is not encrypted, and who is writing to whom stays visible [4].
The last few characters of a fingerprint are enough.Short IDs are unreliable. Compare the full fingerprint [4].
If I lose my private key, I can just make a new one.You can, but others may keep using the old public key. A revocation certificate tells them to stop [2].
Signing a file also hides it.Signing proves who signed and that nothing changed. Only encryption hides the content.

What can I do this week?

  • Next time you download software, look for a signature or checksum on the official site.
  • If you use PGP, check that your private key has a strong passphrase.
  • Make a revocation certificate for your key and store it offline.
  • Compare full fingerprints with one person you exchange encrypted messages with.
  • If your team signs releases, list where each signing key is stored and who or what can use it.

Checklist

  • I can explain the difference between a public key and a private key.
  • I keep my private key secret and protected by a strong passphrase.
  • I have a revocation certificate stored somewhere safe and offline.
  • I check full fingerprints before trusting a key.
  • I do not put private information in the subject line of encrypted email.
  • I check signatures on important downloads when they are offered.
  • Signing keys used by build systems have an owner, a safe store and an expiry date.

Common questions

What is the difference between PGP and GPG?

PGP is the original program and the name people use for the standard, now called OpenPGP. GPG, or GnuPG, is a free program that follows the OpenPGP standard [3]. In daily use, a "PGP key" and a "GPG key" usually mean the same kind of key.

Is it safe to share my public key?

Yes. The public key is meant to be shared, and many people put it on a website or keyserver [2][4]. Others use it to lock messages to you and to check your signatures. It is the private key that must stay secret.

What happens if my private key is stolen?

Publish your revocation certificate so people stop using that key, then make a new key pair. GnuPG notes that a revoked key can still check your old signatures but should not be used to encrypt new messages to you [2]. Tell your regular contacts about the new fingerprint.

Do I need PGP for everyday email?

Usually not. For most people, we suggest an email service with built-in encryption. PGP suits people who need to lock messages across different email services, or check signed files. Our email encryption guide compares the options in plain words.

What does "Verified" next to a code change mean?

On GitHub, it means the change was signed and the signature was checked successfully [8]. It shows which key signed it. It does not prove the code is safe or bug-free, only where it came from.

Where next?

Ready for the detail? Read the practitioner guide: OpenPGP and S/MIME Email Encryption Guide. It goes further into how OpenPGP and S/MIME compare for email, key distribution and running email encryption across an organisation.

Also useful:

Related NHI Mgmt Group resources: HashiCorp GPG Key Exposure 2021 [7], Non-Human Identities for Beginners and Digital Signatures vs Encryption.

Key terms

PGP
A way to encrypt and sign files and email using a pair of keys.
OpenPGP
The open standard that PGP tools, including GnuPG, follow.
Public-private key pair
Two linked keys: a public one you share and a private one you keep secret.
Private key
The secret half of a key pair, used to open locked messages and make signatures.
Digital signature
Proof, made with a private key, of who signed something and that it was not changed.
Web of trust
A way for people to vouch for each other's keys by signing them.
GPG signing key
A private GPG key used to sign files, releases or code changes.

Sources and further reading

  1. IETF, "OpenPGP", RFC 9580, July 2024. https://www.rfc-editor.org/rfc/rfc9580.html (accessed 2 Dec 2026).
  2. The GNU Privacy Handbook, "Getting Started". https://www.gnupg.org/gph/en/manual/c14.html (accessed 2 Dec 2026).
  3. The GnuPG Project, "The GNU Privacy Guard" (home page). https://www.gnupg.org/ (accessed 2 Dec 2026).
  4. Free Software Foundation, "Email Self-Defense". https://emailselfdefense.fsf.org/en/ (accessed 2 Dec 2026).
  5. The GNU Privacy Handbook, "Validating other keys on your public keyring". https://www.gnupg.org/gph/en/manual/x334.html (accessed 2 Dec 2026).
  6. The GNU Privacy Handbook, "Encrypting and decrypting documents". https://www.gnupg.org/gph/en/manual/x110.html (accessed 2 Dec 2026).
  7. HashiCorp, "HCSEC-2021-12: Codecov Security Event and HashiCorp GPG Key Exposure", 22 April 2021 (updated 4 May 2021). https://discuss.hashicorp.com/t/hcsec-2021-12-codecov-security-event-and-hashicorp-gpg-key-exposure/23512 (accessed 2 Dec 2026).
  8. GitHub Docs, "About commit signature verification". https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification (accessed 2 Dec 2026).

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.