π Everything You Need to Know About PGP: Setup, Encryption, Decryption & Usage

What is PGP?

PGP (Pretty Good Privacy) is a widely used encryption program that provides cryptographic privacy and authentication for data communication. It enables you to:
- Encrypt messages and files
- Verify authenticity through digital signatures
- Ensure that only the intended recipient can read content
PGP uses a combination of symmetric and asymmetric encryption. It relies on public and private keys to encrypt and decrypt data securely. The most widely used open-source implementation is GnuPG (GPG).
π§ Installing GPG
On Linux (Debian/Ubuntu)
sudo apt update
sudo apt install gnupg
On macOS
brew install gnupg
On Windows
Download Gpg4win:
π https://gpg4win.org
π How PGP Works (Quick Overview)
- You generate a key pair (public & private)
- You share your public key
- Others encrypt messages using your public key
- You decrypt using your private key

π Generating a Key Pair
Run:
gpg --full-generate-key
Follow the prompts:
- Select key type (default RSA and RSA is fine)
- Choose key size β enter
4096
- Set an expiration date or
0
for no expiration - Enter your name and email (or a placeholder like
anon
) - Create a secure passphrase
To list your keys:
gpg --list-keys
gpg --list-secret-keys
π€ Exporting Your Public Key
Share your public key with others:
gpg --armor --export [email protected] > my_public_key.asc
This creates a text file you can send or upload.
π₯ Importing Someoneβs Public Key
If you receive a key file:
gpg --import their_key.asc
Then verify:
gpg --list-keys
π Encrypting Files or Messages
Encrypt a File Using Public Key
gpg --encrypt --recipient KEYID file.txt
This creates file.txt.gpg
, encrypted for the recipient.
Encrypt a Text Message
echo "Secret message" | gpg --encrypt --armor --recipient KEYID
π Decrypting Files or Messages
Decrypt a File
gpg --output decrypted.txt --decrypt file.txt.gpg
Decrypt an ASCII Message
gpg --decrypt
Paste your message, then press Ctrl+D
(Linux/macOS) to finish.
π Symmetric Encryption (No Key Pair Needed)
Encrypt with a Password
gpg --symmetric file.txt
Decrypt Symmetric File
gpg --output file.txt --decrypt file.txt.gpg
βοΈ Signing Files and Messages
Sign a File
gpg --sign file.txt
Create a Readable Signed Message
gpg --clearsign message.txt
Verify a Signed Message
gpg --verify message.txt.asc
π§Ή Deleting Keys
Delete a Secret (Private) Key
gpg --delete-secret-keys KEYID
Delete a Public Key
gpg --delete-key KEYID
To find KEYID:
gpg --list-keys
πΎ Backing Up Keys
Export Public Key
gpg --armor --export KEYID > public.asc
Export Private Key
gpg --armor --export-secret-keys KEYID > private.asc
β οΈ Store your private key securely and offline.
π‘οΈ Best Practices
- Use
4096
bit keys - Use a strong passphrase
- Never share your private key
- Always verify key fingerprints before using someoneβs public key
- Backup your private key and create a revocation certificate
π₯ GUI Options (Optional)
- Windows: Kleopatra
- macOS: GPG Keychain
- Linux: Seahorse (GNOME)
Examples
examples of PGP keys can be found here
https://tor.link
π Summary
PGP is a powerful tool for encrypting files and messages, signing documents, and protecting digital communications. With GnuPG, itβs free and available across platforms. Once you understand how keys and encryption work, it becomes an essential part of any security-conscious workflow.