Skip site navigation (1) Skip section navigation (2)

MD5 in pg and php

From: Joolz <joolz(at)xs4all(dot)nl>
To: list-postgresql-php <pgsql-php(at)postgresql(dot)org>
Subject: MD5 in pg and php
Date: 2004-04-29 07:07:16
Message-ID: 20040429070716.GA6918@localhost.localdomain (view raw, whole thread or download thread mbox)
Lists: pgsql-php
Hi, I'm completely new to hashing, so please bear with me.

I want to store passwords in a pg db, MD5 seems like a good way to
enhance security (no more plaintext passwords over the line etc.) I
had a look at MD5, in PHP 4.3.4 there is a function md5() which seems
to work nicely:

  echo md5('apple');

returns ae6d32585ecc4d33cb8cd68a047d8434 every time. Apart from the
PHP frontend, I also want to be able to use the same algorithm in
native pg. I found that postgresql-contrib-7.3.4 has a function
crypt() which I expected to work the same. However:

  select crypt('apple', gen_salt('md5'));

gives values different from the PHP md5() function, and moreover,
they're different each time. Can anyone please tell me what I should
do to get the same result in native pg as in PHP?


Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2188.nptl


pgsql-php by date

Next:From: JoolzDate: 2004-04-29 08:15:30
Subject: Re: MD5 in pg and php
Previous:From: Dani MezherDate: 2004-04-28 19:08:02
Subject: Re: HELP!!!! UNICODE problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group