# GPG ## Symmetric Encryption (password-based) ```bash gpg -c file.txt # encrypt → file.txt.gpg gpg file.txt.gpg # decrypt → file.txt ``` ## Asymmetric Encryption (public key) **Encrypt for a recipient:** ```bash gpg -e -r [email protected] file.txt # → file.txt.gpg ``` **Decrypt:** ```bash gpg -d file.txt.gpg > file.txt ``` ## Sign and Encrypt ```bash gpg -s -e -r [email protected] file.txt ``` ## Key Management ```bash gpg --gen-key # generate a new key pair gpg --list-keys # list public keys gpg --list-secret-keys # list private keys gpg --export -a "Name" > public.key # export public key gpg --import public.key # import someone's public key ``` --- See also: [[OpenSSL]] (password-based file encryption), [[Age]] (simpler, modern alternative), [[SSH]]