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 1B67D11F6911 for ; Thu, 6 Apr 2006 15:23:32 -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 37689-05 for ; Thu, 6 Apr 2006 15:23:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from bach.incentre.net (bach.incentre.net [198.161.96.4]) by postgresql.org (Postfix) with ESMTP id 38D0011F6944 for ; Thu, 6 Apr 2006 15:23:28 -0300 (ADT) Received: from sigurd.incentre.net (sigurd.incentre.net [206.75.213.195]) by bach.incentre.net (8.12.9p2/8.12.9) with ESMTP id k36INScQ046906 for ; Thu, 6 Apr 2006 12:23:28 -0600 (MDT) (envelope-from guy@incentre.net) Subject: Re: pgcrypto-crypt From: Guy Fraser To: pgsql-sql@postgresql.org In-Reply-To: References: Content-Type: text/plain Date: Thu, 06 Apr 2006 12:23:27 -0600 Message-Id: <1144347808.15065.18.camel@sigurd.incentre.net> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-7) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200604/44 X-Sequence-Number: 24853 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, > plz anybody give me the function to decrypt that encrypted value..... > plz reply asap I found this with Google, maybe it will help you. CREATE TABLE crypto ( id SERIAL PRIMARY KEY, title VARCHAR(50), crypted_content BYTEA ); 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')); SELECT * FROM crypto; SELECT *,decrypt(crypted_content, 'fooz', 'aes') FROM crypto; SELECT *,decrypt(crypted_content, 'fooz', 'aes') FROM crypto WHERE decrypt(crypted_content, 'fooz', 'aes') = 'struck'; I could not test it, since I do not have pgcrypto installed.