I am working on encrypting a column in a postgre table using pgcrypto
. The postgre version is 9.5.1. I have figured out how to encrypt using pgp_sym_encrypt()
and decrypt using pgp_sym_decrypt()
. My problem is figuring out how to keep the key hidden.
I am trying to avoid having the application decrypt the data that is returned. The data in this table is only sensitive if someone can view the entire table (450,000 rows) and put the data together, so its ok for the data to return to the application decrypted.
In pgAdmin, I have this in my query
SELECT pgp_sym_decrypt(column1,'password')
Obvisouly, I don't want the query template our application uses to have the password stored in it and then pass it in everytime a query is ran. Any ideas would be appreciated?