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 AA216D1E06E for ; Thu, 29 Apr 2004 04:31:29 -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 19227-09 for ; Thu, 29 Apr 2004 04:31:09 -0300 (ADT) Received: from smtp.lewczuk.com (118.224.149.195.tld.pl [195.149.224.118]) by svr1.postgresql.org (Postfix) with SMTP id 6A252D1E406 for ; Thu, 29 Apr 2004 04:31:06 -0300 (ADT) Received: (qmail 19830 invoked by uid 700); 29 Apr 2004 07:31:04 -0000 Received: from linux.samar.pl (HELO lewczuk.com) (marek@lewczuk.com@62.233.139.198) by 118.224.149.195.tld.pl with SMTP; 29 Apr 2004 07:31:04 -0000 Message-ID: <4090BD52.9060708@lewczuk.com> Date: Thu, 29 Apr 2004 09:31:14 +0100 From: Marek Lewczuk 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> In-Reply-To: <20040429070716.GA6918@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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/50 X-Sequence-Number: 2707 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.