These are notes from installing GnuPG for email encryption. The installation was done via Homebrew. When I searched for gpg in Homebrew, “gpg” and “pgp2” came up, but I didn’t understand the difference, so I used “gpg”.
$ brew install gpg
Key generation can also be done with a single command “gpg –gen-key”.
$ gpg --gen-key
gpg (GnuPG) 1.4.13; Copyright (C) 2012 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
gpg: directory `/Users/bobuhiro11/.gnupg' created
gpg: new configuration file `/Users/bobuhiro11/.gnupg/gpg.conf' created
gpg: WARNING: options in `/Users/bobuhiro11/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/Users/bobuhiro11/.gnupg/secring.gpg' created
gpg: keyring `/Users/bobuhiro11/.gnupg/pubring.gpg' created
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection?
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: bobuhiro11
Email address: bobuhiro11@gmail.com
Comment:
You selected this USER-ID:
"bobuhiro11 (Website : http://bobuhiro11.net) <bobuhiro11@gmail.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
.....+++++
..............+++++
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
+++++
......+++++
gpg: /Users/bobuhiro11/.gnupg/trustdb.gpg: trustdb created
gpg: key 804CEC27 marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
pub 2048R/804CEC27 2013-03-09
Key fingerprint = 98D3 4473 A254 D77A BEB1 1776 1172 8D78 804C EC27
uid bobuhiro11 <bobuhiro11@gmail.com>
sub 2048R/8B0DC21D 2013-03-09
Checking Your Public and Private Keys
$ gpg --export -a > public .asc #public key
$ gpg --export-secret-key -a > secret.asc #private key
“gpg –import public_key”
$ gpg --import pubic.asc
$ cat test.txt
Hello bobuhiro11!!!!!!!
$ gpg -r bobuhiro11 -ea test.txt
$ cat test.txt.asc
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.13 (Darwin)
hQEMA33pd/CLDcIdAQgAm6W8gobXgspvTflLgA2kxEyWa5Jgt5ffuuVxIDOzeHX2
nlDUYpeNmYyOwuNTRXG45yeDcTEzLyda4XoQJ1QVVbYY365tW5S4cx/l0YDc20Ao
KHwGGF9EG8UC4GyUaMTWKqG/QFR/4drFnG7vkiChcnlq4A1P9Y1DTTbxohkaAWq5
emtyma1cq56KgOzm5HLf3lWg9qjE9MJCoRj8TIo0IlZKfYk/4ZjkLLrl9aha9NKh
JTnRWe5JW6JBxkKcZE8kcDl5Kz3OkiawIGaXgxZ7rZhQ7/8ZyFUdPmk0er2rokMp
vc6PfiZa4R9yJ3AIZJh2eP69RMxsMvJ8R+D18DyE5dJWAUb+NPz73AIoHpykMWlS
9gC1BpdYwlrO1PptFEz+M+/Xzryn3QMlrCd4ijwWubm/1JJ5lixyFVpc9XPHoJLI
se0Kf5xLuw2PWNl6wAiSD904SxWpO18=
=ushx
-----END PGP MESSAGE-----
$ gpg -d test.txt.asc
You need a passphrase to unlock the secret key for
user: "bobuhiro11 <bobuhiro11@gmail.com>"
2048-bit RSA key, ID 8B0DC21D, created 2013-03-09 (main key ID 804CEC27)
gpg: encrypted with 2048-bit RSA key, ID 8B0DC21D, created 2013-03-09
"bobuhiro11 <bobuhiro11@gmail.com>"
Hello bobuhiro11!!!!!!!
Here, I’m just encrypting and decrypting by myself (lol) This should be enough for now.