How to encrypt a column using PostgreSQL pgcrypto

10 June,2022 by Rambler

There are different types of encryption supported by PostgreSQL. If the requirement is to support encryption for specific fields - look into the  pgcrypto module 

 

create table cryptosource (ID INT , avalue varchar(30));

insert into cryptosource (ID , avalue)
select 1 , 'bcbcbcbc'

CREATE EXTENSION pgcrypto;

SELECT avalue, crypt(avalue, gen_salt('md5')) AS hashed_value
FROM cryptosource;

 

'sha1' is an alternative option to 'md5'

 

 


Author: Rambler (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to encrypt a column using PostgreSQL pgcrypto


dba-ninja.com