Database column encryption postgres Database column encryption postgres database database

Database column encryption postgres


Yes, Postgres pgcrypto module does support AES. All details with examples can be found here. As for the sample usage:

-- add extensionCREATE EXTENSION pgcrypto;-- sample DDLCREATE TABLE test_encrypt(  value TEXT);INSERT INTO test_encrypt VALUES ('testvalue');-- encrypt valueWITH encrypted_data AS (  SELECT crypt('PasswordToEncrypt0',gen_salt('md5')) as hashed_value)UPDATE test_encrypt SET value = (SELECT hashed_value FROM encrypted_data);

Validate password:

SELECT (value = crypt('PasswordToEncrypt0', value)) AS match FROM test_encrypt;

Returns:

 match ------- t(1 row)