Pgp postgres
Jump to navigation
Jump to search
https://hardyantz.medium.com/data-encryption-in-postgresql-a4b51a60dfc2
-- Assuming you have a public key named 'my_public_key' already imported into your keyring
-- Encrypting a message
SELECT pgp_pub_encrypt(
'Your secret message here',
keys.keydata
) AS encrypted_message
FROM (
SELECT pgp_pub_decrypt(key, 'my_secret_passphrase') AS keydata
FROM pgp_keys
WHERE key_id = 'my_public_key'
) AS keys;