Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 36CF79FBC1D for ; Mon, 4 Jun 2007 20:18:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 29943-08 for ; Mon, 4 Jun 2007 20:18:46 -0300 (ADT) X-Greylist: delayed 00:23:52.568619 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id DA5A09FBB7E for ; Mon, 4 Jun 2007 20:18:51 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mx01.burntmail.com (mx01.burntmail.com [69.93.121.66]) by svr4.postgresql.org (Postfix) with ESMTP id C66675AF03A for ; Mon, 4 Jun 2007 22:54:57 +0000 (GMT) Received: from pool-72-66-94-73.washdc.fios.verizon.net ([72.66.94.73] helo=[127.0.0.1]) by mx01.burntmail.com with esmtpa (Exim 4.63) (envelope-from ) id 1HvLRy-0005XN-Qb for pgsql-general@postgresql.org; Mon, 04 Jun 2007 17:54:59 -0500 Message-ID: <4664983F.4010700@burntmail.com> Date: Mon, 04 Jun 2007 18:54:55 -0400 From: Guy Rouillier User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: Encrypted column References: <46645B01.6070605@terra.com.br> In-Reply-To: <46645B01.6070605@terra.com.br> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 000747-0, 06/04/2007), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/363 X-Sequence-Number: 115186 Ranieri Mazili wrote: > Hello, > > I need to store users and passwords on a table and I want to store it > encrypted, but I don't found documentation about it, how can I create a > table with columns "user" and "password" with column "password" > encrypted and how can I check if "user" and "password" are correct using > a sql query ? Many people consider two-way encryption to be insecure; two-way encryption means you can decrypt a value if you know the key, and it is insecure because you usually have to put the key into the source code. That means at least one person in your company, the programmer maintaining the source code, can learn all of your users' passwords. One way around that is to hash the value instead. Then to validate, at runtime you hash the user-entered password using the same hash function, and validate that it matches the stored hash. No one in your company ever knows end-user passwords. -- Guy Rouillier