(Wikipedia) Pretty Good Privacy (PGP) is an encryption program that provides cryptographic privacy and authentication for data communication. PGP is used for signing, encrypting, and decrypting texts, e-mails, files, directories, and whole disk partitions and to increase the security of e-mail communications. Phil Zimmermann developed PGP in 1991.
This guide is meant for linux users (i will add MacOS and Windows in the future) using the gpg (GNU Pricacy Guard) package.
First, create your public and private keys:
gpg --full-generate-key
For just getting started:
Verify your key was created:
gpg --list-keys
gpg --armor --export your@email.com
Share your public key with people who want to send you encrypted messages:
You can then share the contents of public-key.asc with others.
gpg --armor --export your@email.com > public-key.asc
Before you can encrypt a message for someone, you need their public key:
gpg --import their-public-key.asc
Encrypt a message for someone (you'll need their email address from their key):
echo "Your secret message here" | gpg --armor --encrypt --recipient their@email.com
Or encrypt a file:
gpg --armor --encrypt --recipient their@email.com message.txt
The encrypted output starts with -----BEGIN PGP MESSAGE----- and can be copy-pasted into a chat.
When you receive an encrypted message, decrypt it with:
gpg --decrypt encrypted-message.asc
Or paste the encrypted text directly:
echo "-----BEGIN PGP MESSAGE----- ... -----END PGP MESSAGE-----" | gpg --decrypt
You'll be prompted for your passphrase.
| Command | Purpose |
|---|---|
gpg --list-keys |
List all public keys |
gpg --list-secret-keys |
List your private keys |
gpg --delete-key EMAIL |
Delete a public key |
gpg --armor --export EMAIL |
Export public key to terminal |