Last active
January 12, 2016 04:31
-
-
Save rietta/79900d8df4d7a6adb85d to your computer and use it in GitHub Desktop.
Encrypts a hello world greeting to my personal public PGP key that's published at https://keybase.io/rietta.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
ARMOR(PGP_PUB_ENCRYPT( | |
'Hello, World', | |
DEARMOR('-----BEGIN PGP PUBLIC KEY BLOCK----- | |
Version: GnuPG v2 | |
mQINBFPRvdYBEACeM7pbpqxheVpIkfNSt1I//MLMmmvV/2XlJFj0z4zTOZPU5KTl | |
DNpfV0bHSUU5pOs9hSkM5WP+uWTAl/X5a5Ty7Vdr0r//sYNYt05ummAZQEwfaSzj | |
Ys57Ks1yC/31SOM/bOvWOIf/+D/GVAEuJTdfwic/Vv56ixuk8skLjWTmxBBCFpbF | |
dEXWyxuADvftrhaGq16xaOx0vLFxagL7mpIEjVN2yYadR5iMm1g48lAG6Tc/JEPY | |
tDXzctfzHoPmPY93tk86vbHS7osA3R323LWnE3DgDRZ5Ux75+xGFjYiJLeUfuiqY | |
FB4/MefjvnnxXryHQf7LiKLbW++TsUBRGtXa/ebjixX440IP4EHEZK76F0U+EvQw | |
WMIP6QrOXLaa8sX2w8wjo3R8qnSIg8Dl93qK5qJ2jVsamCzsuDONieyiiuThLN92 | |
LEYpc0rrvzgx5Ims98Cob/k7X0eHO57TxrnhpOEymwnyJnGaBwwlJzup8uEWo6kN | |
I09Hj6GcBP6acY8knSasnTIjrIET+3PH1NshFO1A6bo6dkASOZNCLzdxvNQ2RcxP | |
Rczmj0AoY4UKRDRYRo2OSS6RgfBAfRuCMq2Sb1KUWwhwt1Td67rl7PWM3Fj/E8Hj | |
7q5UfaHL0NSWaHRP23QzYAws9VDGQYv6sGC/BEfxP9IDF3zHew1ZyK2dLwARAQAB | |
tCJGcmFuayBTLiBSaWV0dGEgPGZyYW5rQHJpZXR0YS5jb20+iQJABBMBCgAqAhsD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bGfv61VDyE3yX6q8qpZ5y | |
iChky5yTrKJ3i5GikdTSeb1VSGOCjg== | |
=Q+PC | |
-----END PGP PUBLIC KEY BLOCK-----') | |
)) AS message; |
Cool!
These are the setup instructions on a brand new Ubuntu Linux server instance (probably also applies to Debian).
Install both postgresql and postgresql-contrib (important).
sudo apt-get install postgresql postgresql-contrib
Enabling pgcrypto for a database requires superuser privileges so,
sudo su -l postgres
ENTER YOUR SUDO PASSWORD
psql project_database
CREATE EXTENSION pgcrypto;
\q
exit
Return to your project database needs using the regular non-root, non-admin user with access to the encryption database encryption functions documented in http://www.postgresql.org/docs/9.4/static/pgcrypto.html.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One example invocation resulted in:
Which I can decrypt, but no one else can.