Assumes recipient does not yet have sender's public key.
gpg --gen-key
= Create public and private key pair.gpg --output file.sig --detatch-sign file.txt
= Sign file.txt with private key, producing the signature file file.sig.gpg --export --armor "pubkey.gpg" > public.asc
= Export binary public key to ASCII-encoded string.- Transfer file.sig, file.txt, and public.asc to recipient.
gpg --import public.asc
= Import sender's public key.gpg --verify file.sig file.txt
= Verify the file.sig signature of file.txt using sender's public key.
- Encrpyt file.txt using recipient's public key (assuming it's in the gpg keychain), then sign file.txt using sender's private key:
gpg --encrypt --sign --armor --recipient recipient@example.com file.txt
- This produces the encrypted and signed file
file.txt.asc
.
- Decrypt file.txt using recipient's private key and verify sender's signature:
gpg --decrypt file.txt.asc > file.txt
- Encrypt file.txt into file.gpg using a password that must be provided:
gpg --output file.gpg --symmetric file.txt
- Decrypt file.gpg into file.txt using the same password used to encrypt file.txt:
gpg --decrypt file.gpg