X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5228ED1E1ED for ; Thu, 29 Apr 2004 05:51:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 43875-05 for ; Thu, 29 Apr 2004 05:50:56 -0300 (ADT) Received: from obie.mrkdns.com (obie.mrkdns.com [69.93.72.82]) by svr1.postgresql.org (Postfix) with ESMTP id 5270AD1E5BF for ; Thu, 29 Apr 2004 05:50:49 -0300 (ADT) Received: from [213.152.63.90] (helo=chuckie.co.uk) by obie.mrkdns.com with asmtp (Exim 4.30) id 1BJ7Fl-0002LJ-Ot for pgsql-php@postgresql.org; Thu, 29 Apr 2004 09:50:45 +0100 Message-ID: <4090C1E0.6010309@chuckie.co.uk> Date: Thu, 29 Apr 2004 09:50:40 +0100 From: Nick Barr User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: Re: MD5 in pg and php References: <20040429070716.GA6918@localhost.localdomain> <4090BD52.9060708@lewczuk.com> <20040429081530.GA8282@localhost.localdomain> In-Reply-To: <20040429081530.GA8282@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - obie.mrkdns.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - chuckie.co.uk X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/54 X-Sequence-Number: 2711 Joolz wrote: >>[Marek Lewczuk schreef op 29-04-2004 09:31 +0100] >> >>Joolz wrote: >> >> >>>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? >>> >>>Thanks! >>> >>> >>> >>I whould suggest to update PG to version 7.4, where there is built-in >>MD5 function. >> >> > >Thanks, I already found some fc1 rpm's (still in development). But can >anyone tell me if the 7.4 internal md5() function will do the same as >the PHP md5() function? Or do a quick select md5('apple') and let me >know if the result is 'ae6d32585ecc4d33cb8cd68a047d8434'? > >I really wouldn't like to upgrade from my current stable situation, >only to find out that it didn't solve my original problem. > >TIA! > > > OK, PHP --------------------------------------------------- --------------------------------------------------- produces --------------------------------------------------- 1f3870be274f6c49b3e31a0c6728957f --------------------------------------------------- and postgres: --------------------------------------------------- im_perf=# select version(); version --------------------------------------------------------------------------------------------------------- PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1) (1 row) im_perf=# select md5('apple'); md5 ---------------------------------- 1f3870be274f6c49b3e31a0c6728957f (1 row) --------------------------------------------------- I have no idea why these two results dont agree with yours, but at least they agree with each other. It is probasbly different library versions. Nick