X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 43E4611F6956 for ; Thu, 6 Apr 2006 15:31:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41926-02 for ; Thu, 6 Apr 2006 15:31:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from nelson.osl.com (216-21-133-120.ip.van.radiant.net [216.21.133.120]) by postgresql.org (Postfix) with ESMTP id 5AA4F11F6947 for ; Thu, 6 Apr 2006 15:31:43 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Subject: Re: pgcrypto-crypt Date: Thu, 6 Apr 2006 11:31:41 -0700 Message-ID: <144D12D7DD4EC04F99241498BB4EEDCC2883A8@nelson.osl.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] pgcrypto-crypt Thread-Index: AcZZpz+mOiZU6O3DTXGkWzBxHwxvXgAAE6/w From: "Owen Jacobson" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200604/45 X-Sequence-Number: 24854 Guy Fraser wrote: =20 > On Thu, 2006-06-04 at 13:53 +0530, AKHILESH GUPTA wrote: > > dear all, > > i want to encrypt and decrypt one of the fields in my table (i.e- > > password field) > > i have searched and with the help of pgcrypto package, using = function > > "crypt", i am able to encrypt my data, > > but there is nothing which i found to decrypt that same data, The 'crypt' function in pgcrypto is analogous to the unix crypt(3) = function, which is actually a hashing function and not an encryption = function -- meaning you *can't* (realistically) decrypt it. Use = 'encrypt', as demonstrated below. > INSERT INTO crypto VALUES (1,'test1',encrypt('daniel', 'fooz', = 'aes')); > INSERT INTO crypto VALUES (2,'test2',encrypt('struck', 'fooz', = 'aes')); > INSERT INTO crypto VALUES (3,'test3',encrypt('konz', 'fooz', 'aes')); >=20 > SELECT * FROM crypto; >=20 > SELECT *,decrypt(crypted_content, 'fooz', 'aes') FROM crypto; >=20 > SELECT *,decrypt(crypted_content, 'fooz', 'aes') FROM crypto WHERE > decrypt(crypted_content, 'fooz', 'aes') =3D 'struck'; >=20 > I could not test it, since I do not have pgcrypto installed. This works perfectly.