GnuPG is a complete and free implementation of the OpenPGP standard encryption.
GPG is available in Windows and many distributions of Linux, including a graphical user interface (GUI) that is easy to use. However, I prefer using the command line tools instead.
Red Hat / CentOS
sudo yum install gnupg
Ubuntu / Debian
sudo apt-get install gnupg
Note: Use gpg2 (version 2.x)
Mac OS X
GPG is best installed on MacOS using Homebrew. Once Homebrew is installed, install GPG.
brew install gnupg
Check the version of the command line tools you are running or have installed
Creating GPG keys
Generate your own GPG key pair which will be used to encrypt and decrypt files.
Exporting public keys
Your public key is the one that you can share to whom ever you will receive your message from. In other words, other other person will use your public key to encrypt their message when they send to you. You will be able to decrypt that message using your private key.
gpg --export --armor email@example.com > pubkey.asc
Exporting secret keys
Keep your private key in a safe place and never share it with anyone.
gpg --export-secret-keys --armor firstname.lastname@example.org > secretkey.asc
You can import others' public key or another private key
gpg --import publickey.asc
Listing public keys
Listing secret keys
Encrypting a file
gpg -r "Name" -e secretfile.txt
Encrypting multiple files
gpg -r "Name" --encrypt-files $(ls $DIR/secretfile*.txt)
Decrypt a file to disk
Deleting public keys
gpg --delete-key [key-ID]
Deleting secret keys
gpg --delete-secret-key [key-ID]