postgresql - Database column encryption postgres -
how encrypt column in postgres database using pgcrypto addon ?
i using postgres 9.3 , need encrypt 1 of column , postgres support aes encryption or mean can achieve ?
yes, postgres pgcrypto
module support aes
. details examples can found here. sample usage:
-- add extension create extension pgcrypto; -- sample ddl create table test_encrypt( value text ); insert test_encrypt values ('testvalue'); -- encrypt value encrypted_data ( select crypt('passwordtoencrypt0',gen_salt('md5')) hashed_value ) update test_encrypt set value = (select hashed_value encrypted_data);
validate password:
select (value = crypt('passwordtoencrypt0', value)) match test_encrypt;
returns:
match ------- t (1 row)
Comments
Post a Comment