Re: How to encrypt data in Postgresql

From: Douglas Trainor <trainor(at)uic(dot)edu>
To: Terence Chang <TChang(at)nqueue(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to encrypt data in Postgresql
Date: 2003-07-24 21:28:54
Message-ID: 3F204F96.5050608@uic.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

biguns> psql dados
Welcome to psql 7.3.3, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

dados=# select encode(digest('texto', 'md5'), 'hex');
encode
----------------------------------
62059a74e9330e9dc2f537f712b8797c
(1 row)

Of course, you'd probably have a field instead of 'texto', but you get
the idea.
And you will first need to suck in the contributed code from Marko Kreen
and the WIDE Project, which if you have the source will be in the directory
postgresql-7.3.3/contrib/pgcrypto

There are many variations on how you can use md5. You could do it in PHP,
or you could do it closer to the database...

douglas

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!
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dennis Gearon 2003-07-24 21:43:02 Re: SAP DB: The unsung Open Source DB
Previous Message greg 2003-07-24 21:21:17 Re: List last value of all sequences