
What is GPG?
GPG stands for GNU Privacy Guard and is a way to get end to end encryption and secure communication through an insecure communication channel. GPG can generate a key pair (Public key and Private key) You can encrypt a message with someones public key and that message can only be decrypted by their private key. By sharing just the Public keys, two people can securely communicate with each other. This makes the Confidentially from the CIA triad strong. On top of this, the private key can sign messages to verify who a message came from.
On top of signing messages and secure communication, GPG can be used for encrypting your own data. Simply encrypt with your own public key and store your data on the cloud. Be at ease knowing that even if there is a data breach, you are secure.
How do I use GPG?
Creating a GPG key pair
Before we can get to encrypting you will need to generate a key pair. To do this simply run ‘gpg –full-gen-key’. Follow the promps and use ECC over RSA. Remember to use a strong password.
Adding public keys to GPG
To add someones public key to your GPG keyring, you just run ‘gpg –import pubKey.asc’
Getting your public key
To get your own public key to share just run ‘gpg –armor –export email@domain.com’
Encrypting data
The way you encrypt a file with GPG is as follows; ‘gpg -r email@domain.com -e fileToEncrypt’. The ‘-r’ flag is for recipient (The person you want to encrypt for) and the -e flag is for encrypt. After running the command you will now have fileName.gpg as a encrypted file.
decrypting data
The way you decrypt a file with GPG is by runnign ‘gpg -d encryptedFile.gpg’. This will output the message through the standard output so if you want it to save to a file you run ‘gpg -d encryptedFile.gpg > decryptedFile’.