PGP Examples

Examples for MacOS, Windows and Linux.

Generate a key pair

$ gpg --gen-key
$ gpg -k	# list keys

Export keys

$ gpg --output "my public.key" --export -a
$ cat "my public.key"
$ gpg --output "my private.key" --export-secret-key -a
$ cat "my private.key"
Remember that the private key is a secret and should not be published.

Encrypt and decrypt files

$ gpg --encrypt --sign -r secretMessage.txt
$ ls secretMessage.txt.gpg
$ rm -f secretMessage.txt
$ gpg --output secretMessage.txt --decrypt  -r secretMessage.txt.gpg
$ cat secretMessage.txt
Find out MORE about PGP and computer security HERE.