Re: pgcrypto-crypt

From: Guy Fraser <guy(at)incentre(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: pgcrypto-crypt
Date: 2006-04-06 18:23:27
Message-ID: 1144347808.15065.18.camel@sigurd.incentre.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Eric E 2006-04-06 18:26:34 Re: "Upcalls" (sort of) from the database
Previous Message Tom Lane 2006-04-06 18:16:25 Re: Database lost after reboot

Browse pgsql-sql by date

  From Date Subject
Next Message Owen Jacobson 2006-04-06 18:31:41 Re: pgcrypto-crypt
Previous Message Eugene E. 2006-04-06 13:20:16 Re: have you feel anything when you read this ?