Re: How to encrypt data in Postgresql - Mailing list pgsql-general

From Franco Bruno Borghesi
Subject Re: How to encrypt data in Postgresql
Date
Msg-id 1059073198.1218.6.camel@taz
Whole thread Raw
In response to How to encrypt data in Postgresql  ("Terence Chang" <TChang@nqueue.com>)
Responses Re: How to encrypt data in Postgresql  ("Reuben D. Budiardja" <techlist@voyager.phys.utk.edu>)
List pgsql-general
You must install pgcrypto (its in your contrib/pgcrypto directory).

Then, the functions crypt and gen_salt will become available.

As an example, to insert a new user (peter) with an encrypted password (1234) you can do:
INSERT INTO myUsers(name, pass) VALUES ('peter', crypt('1234', gen_salt('md5'));

To verify that <anypassword> is OK:
SELECT (<anypassword>=crypt(<anypassword>, pass)) WHERE name='peter';

The package includes many other functions, listed in README.pgcrypto.

On Thu, 2003-07-24 at 15:18, Terence Chang wrote:
Hi there:
 
I know this might be an easy answer, but I was unable to figure out the solution.
 
I would like to encrypt a password field in the table. I could not figure out how phpPGAdmin did.
 
Should I use PHP's MD5 to encrypt the password? Is there a function in PostgreSQL that can encrypt the data with MD5?
 
I would like to encrypt the data in PostgreSQL, so other program can use the same function. Can anyone give me some hints? What key word should I search in the document?
 
Thansk!
 
Attachment

pgsql-general by date:

Previous
From: Nailah Ogeer
Date:
Subject: Re: Postgres hash tables
Next
From: Richard Welty
Date:
Subject: Re: How to encrypt data in Postgresql