How to encrypt a file with GPG on Windows (command line and Kleopatra)

GPG (GnuPG) encrypts files with a passphrase or with someone's public key, in the OpenPGP standard format. On Windows it comes with Gpg4win, which also installs Kleopatra, a key manager with windows and buttons. These commands were checked against the GnuPG manual and tested with GnuPG 2.4.

Short answer: install Gpg4win from gpg4win.org, then in PowerShell run gpg -c report.pdf to encrypt with a passphrase, or gpg -e -r alex@example.com report.pdf to encrypt for someone's public key. Both create report.pdf.gpg and leave the original in place. Decrypt with gpg -o report.pdf -d report.pdf.gpg. If you lose the passphrase or your secret key, you can't decrypt the file and nobody can do it for you, so back up your key.

1. Install Gpg4win and check it

Gpg4win is the official GnuPG distribution for Windows, maintained by the GnuPG developers. It installs GnuPG (the gpg command), Kleopatra, GpgOL for Outlook and GpgEX for File Explorer. Version 5.1.1 came out on 2026-09-23. It supports Windows 10 (version 1809 or later) and Windows 11; since version 5 it runs only on 64-bit systems and is built on GnuPG 2.5. The download page asks for an optional donation ($0 is a choice).

Before you run the installer, check it. Gpg4win's integrity page says the installer is code-signed by g10 Code GmbH: the User Account Control prompt shows the publisher, or right-click the file → Properties → Digital Signatures. The same page lists SHA-256 checksums, which you can compare with:

certutil -hashfile gpg4win-5.1.1.exe sha256

The installer adds GnuPG's bin folder (by default C:\Program Files\GnuPG\bin) to your PATH, so open a new PowerShell window and run gpg --version. If it isn't found, run & "C:\Program Files\GnuPG\bin\gpg.exe" --version. Git for Windows has its own gpg, so in Git Bash you may get that copy; the version and Home folder shown tell you which.

2. Encrypt a file with a passphrase

gpg -c report.pdf

A Pinentry window asks you to choose a passphrase, and gpg writes report.pdf.gpg. The manual says -c (--symmetric) uses AES-256 by default; gpg -c --cipher-algo AES256 report.pdf makes that explicit. Don't use --cipher-algo for public-key encryption: the manual says it lets you violate the OpenPGP standard, and without it gpg uses the preferences stored with the key. Add -a (--armor) for text output you can paste into an email.

One surprise: gpg caches the passphrase for symmetric encryption, so decrypting soon afterwards may not ask for it. To check you really can decrypt, add --no-symkey-cache.

3. Encrypt a file with someone's public key

First, if you don't have a key pair, make one with gpg --full-generate-key (it asks about every option) or gpg --quick-generate-key "Your Name <you@example.com>". Share your public key with gpg --armor -o my-public-key.asc --export you@example.com. Then import the recipient's key, check its fingerprint, and certify it:

gpg --import alex-public.asc
gpg --fingerprint alex@example.com
gpg --lsign-key alex@example.com

Compare the fingerprint with Alex over the phone or in person before you certify: if the key isn't really theirs, someone else can read your file. --lsign-key signs it with your key, marked as not exportable. Without it, gpg warns there's no assurance the key belongs to that person and asks whether to use it anyway. Then encrypt:

gpg -e -r alex@example.com -r you@example.com report.pdf

Each -r (--recipient) adds a person who can decrypt. Include yourself, or you can't open the file you just made.

4. Decrypt

gpg -o report.pdf -d report.pdf.gpg

Pinentry asks for your passphrase (or your key's passphrase). Always give -o (--output): without it, -d writes the decrypted data to the screen. Don't redirect it with > either: Microsoft says PowerShell 7.4 changed redirection to keep a program's output byte for byte, and older versions didn't promise that.

Prefer windows to commands? Use Kleopatra

Kleopatra, installed with Gpg4win, is a certificate manager (it calls keys "certificates") with the common encryption dialogs. It creates key pairs, imports and certifies other people's certificates, and encrypts files and folders for the people you pick. GpgEX adds signing and encrypting to File Explorer's right-click menu; several files and folders selected together become one archive in Gpg4win's gpgtar format.

Back up your key, and what losing it means

gpg --armor -o E:\my-secret-key.asc --export-secret-keys you@example.com

Here E: is a USB stick: export straight to it (or delete any copy left on the PC) and keep it in a drawer, never next to the files it protects. The manual warns that exporting a secret key is a risk if it's sent over an insecure channel. When GnuPG makes a key, it also saves a revocation certificate in the openpgp-revocs.d folder of its home directory. Keep a copy, as safely as the key: anyone who has it can revoke your key.

There is no way around a lost passphrase. To "Help! I lost my passphrase.", the GnuPG FAQ answers "Unfortunately, we can't help you": existing files can't be decrypted. It advises revoking the key and starting again with a new one. Files made with gpg -c depend on their passphrase alone.

Verify a download with GPG

Many projects publish a signature file next to each download. Import the publisher's key, then name both files:

gpg --import publisher-key.asc
gpg --verify setup.exe.sig setup.exe

"Good signature" means the file matches the key. If gpg warns that the key (or its User ID) is not certified with a trusted signature, GnuPG's integrity page says to compare the fingerprint it shows with the one the publisher lists. The manual strongly discourages letting gpg guess the data file, so name both. Don't check a GnuPG download with that same new copy; for Gpg4win, use the code signature.

What can go wrong

  • Lost passphrase or secret key: the files are lost. Back up the key and keep the passphrase somewhere safe.
  • Encrypted only for someone else: you can't open your own copy. Add yourself with a second -r.
  • A tampered file: gpg warns (for example "WARNING: encrypted message has been manipulated!") and exits with an error, but may still write the output file. Delete it.
  • Passphrases in scripts: the manual calls --passphrase "of very questionable security on a multi-user system" and a --passphrase-file "of questionable security if other users can read this file". They work only with --batch and, since GnuPG 2.1, --pinentry-mode loopback. PowerShell saves typed commands to a history file, skipping only lines with words like password or secret.
  • The original stays: gpg doesn't delete report.pdf, and report.pdf.gpg shows the name unless you choose another with -o.

What each option can and can't do

Questiongpg -cgpg -e -rClavis Encrypt
Unlocks withThe passphraseA recipient's secret key and its passphraseYour vault password, or the recovery key
Detects changes to the fileYes, the manual describes integrity protection (MDC or OCB)Yes, sameYes, on every decrypt
Hides the file nameOnly if you choose a meaningless name with -o (gpg keeps the real name inside, encrypted)SameYes, the real name is stored inside
Share without sharing a passwordNoYes, with people who use OpenPGP softwareYes, by Clavis ID (Premium; both people use Clavis)
Forgotten passphrase or lost keyFile is lostFile is lostRecovery key, if you kept it; otherwise lost
CostFreeFreeFree for files; command line in Premium ($29 once)

Where Clavis Encrypt fits

GPG is free and uses a published standard, OpenPGP, which makes it the better choice when you exchange files with people who already use it. If you mainly want to lock your own files with a password and not manage keys, Clavis Encrypt is simpler: choose a file (or several) and press Encrypt. It uses AES-256-GCM with Argon2id, hides the real file name inside the .enc file, and gives you a recovery key in case you forget your password. That's free on Windows 10 and 11 and Linux. Premium ($29 once) adds sharing by Clavis ID and the clavis-cli command line, which comes only with the downloads from clavisenc.com. Clavis is closed source and hasn't been independently audited; its file format is public, with an open-source decryptor.

Questions

How do I encrypt a file with GPG on Windows?

Install Gpg4win, open PowerShell and run gpg -c yourfile to encrypt it with a passphrase. GPG writes yourfile.gpg next to the original. To encrypt for someone else, import their public key and run gpg -e -r their-email yourfile.

How do I encrypt a file with a public key using the gpg command line on Windows?

Run gpg --import with their key file, check the fingerprint with gpg --fingerprint, certify the key with gpg --lsign-key their-email, then run gpg -e -r their-email -r your-email file. Only the people you list with -r can decrypt it.

What's the difference between gpg -c and gpg -e?

gpg -c encrypts with a passphrase you choose, so anyone who knows it can decrypt. gpg -e encrypts for public keys, so only the holders of the matching secret keys can decrypt, and no passphrase has to be shared.

Does gpg -c use AES-256?

Yes. The GnuPG manual says the default cipher for symmetric encryption is AES-256. You can add --cipher-algo AES256 to make it explicit.

I forgot my GPG passphrase. Can I get my files back?

No. The GnuPG FAQ says it can't help: without the passphrase you can't decrypt existing files. Revoke the key with your revocation certificate and create a new one.

Can I use GPG on Windows without the command line?

Yes. Kleopatra, which comes with Gpg4win, creates and manages keys and encrypts and decrypts files in windows, and GpgEX adds encryption to the File Explorer right-click menu.

Sources

Checked against the GnuPG manual (version 2.5.23) and gpg4win.org on November 11, 2026; commands tested with GnuPG 2.4. Gpg4win and Kleopatra change between versions; gpg --help on your own PC is the final word.

Related: encrypting a file with OpenSSL, encrypting files before emailing them and sharing encrypted files without sending a password.

Get Clavis Premium — $29 once Try the free installer first

One-time payment, tax included, no subscription. The command line comes with the installer from clavisenc.com, not the Microsoft Store version, so start with the free installer.