Category Archives: Linux

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-----


Can you post this anywhere? Maybe, maybe not. At least for now, it works with LinkedIn posts. Social networks might change the formatting slightly enough to corrupt your message. But worth trying, just for fun.

Copy-paste this into a file on your PC. Then run gpg --pinentry-mode=loopback test.txt.asc and 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.gpg (filename doesn’t matter.)

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: You don’t necessarily need the -a option for “ascii armored output.” Also this explains why you probably want to use the “loopback” option.