Category Archives: Crypto

Encrypt Your Blog With GPG

I heard about GPG several years ago and finally decided to try it. I ran into some problems, but I figured out a solution that I posted on StackExchange.

What annoyed me though, the output didn’t seem like it would work in a blog. Well, I figured that out too.

Here’s an example test message called test.txt:

start
	start
		testing
		test
	end
end

In Linux, we can encrypt this like…

gpg -ac --pinentry-mode=loopback test.txt

This creates a file called test.txt.asc that looks like this…

-----BEGIN PGP MESSAGE-----

jA0EBwMC3CKSq0cejGbi0lUB/cDbPdO+yRiZMkgpsz6GrcsBshWWc1VwBAaGqDFb
BqGJ/zliE1DY0+CzKreNPhWjqs91+kMiMoMFOHsC8X+dozm+mOlyQ81dVu4jqbJC
fVhsyvSs
=eLuQ
-----END PGP MESSAGE-----


The .asc extension tells you the file contains ASCII characters. Can you post this anywhere? Maybe, maybe not. Social networks might change the formatting slightly enough to corrupt your message. But it’s worth trying for fun.

Copy-paste this text into a file on your PC. Then run gpg --pinentry-mode=loopback test.txt.asc and if necessary use the password: asdf

Does it work with WordPress? Yes and no. Apparently, if you use blockquote, WordPress changes the dashes, so use the code tag instead and it works. (Or just remember to use five dashes, etc.) Paste the encrypted text into whatever.blah

Example:

[]# gpg --pinentry-mode=loopback whatever.blah
gpg: WARNING: no command supplied. Trying to guess what you mean ...
gpg: AES encrypted data
gpg: encrypted with 1 passphrase
gpg: whatever.blah: unknown suffix
Enter new filename [test.txt]:
[]# cat test.txt


start
	start
		testing
		test
	end
end

PS: Without the -a option for “ascii armored output” you get a smaller .gpg digital file that won’t paste into a text editor. Also this explains why you probably want to use the “loopback” option.