Skip to main content

Using OpenGPG

PGP is a popular method for encrypting data. It is a standard for encrypting emails and other data. There are many different implementations of PGP, but the most popular is OpenPGP. Popular tools for PGP are gpg, gpg2, and gpg-agent.

Installing OpenPGP on a Mac

brew install gnupg

Creating a Key

First, you need to create a key. This is done by running the following command:

gpg --gen-key

This actually creates a pair of keys, one for encryption and one for signing. The first key is called the private key, and the second is called the public key. You should always keep the private key safe. The public key is what you share with others.

With the pubic key, anyone can encrypt data that only you can decrypt - using the private key. To share the public key you can export it to a file.

Exporting the Public Key

To export the public key, run the following command:

gpg --armor --export <email> > public_key.asc

Importing the Public Key

To encrypt data, you need to import the public key. This is done by running the following command:

gpg --import public_key.asc

List public keys

To list the public keys, run the following command:

gpg --list-keys

List secret keys

gpg --list-secret-keys

Encrypting a File

To encrypt a file, run the following command:

gpg --encrypt --armor --recipient <email> <file>

Decrypting a File

To decrypt a file, run the following command:

gpg --decrypt <file>

Introducing bcwipe

Another tool that is useful for PGP is bcwipe. This tool is a command line utility that can be used to wipe a block device. It is useful for wiping a hard drive before installing a new operating system.

Downloading bcwipe

To install bcwipe, run the following command:

brew install bcwipe