OpenPGP – Generate keys, encrypt and sign it!


OpenPGP is the most widely used email encryption standard in the world. It is defined by the OpenPGP Working Group of the Internet Engineering Task Force (IETF) Proposed Standard RFC 4880. The OpenPGP standard was originally derived from PGP (Pretty Good Privacy), first created by Phil Zimmermann in 1991.

I’ve been playing around with openPGP lately, so before I forget I need to post a quick intro to openPGP. Otherwise I’ll forget. I’m only using openPGP to encrypt files. It’s super simple, and this can also be used to encrypt files before you send them to your friends. (as long as you have their pulic key..)

Create keys;

$ gpg –gen-key
Please select what kind of key you want: default
What keysize do you want? (2048) 4096
Key is valid for? (0) default
Is this correct? (y/N) y

Real name: First_Name Last_name
Email address:
Comment: Some comment if you want

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o

Enter passphrase: password
Repeat passphrase:password

Encrypt files

$ gpg –armor –recipient Your_Name –encrypt –sign $file

This will encrypt and sign $file with your public key, witch then you can be opened with, and only with, your private key. This command also can be used if you have imported a pubkey from another user. This way you can encrypt a file with recipent public key and he is then the only one who can open it with his private key.

Decrypt files

$ gpg –decrypt $file.asc
$ gpg –output $outputfile –decrypt $file.asc

The first command will decrypt and show content. The second command will decrypt and output content to $outputfile.

Leave a Comments