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