Re: pgcrypto-crypt

Lists: pgsql-generalpgsql-sql
From: "AKHILESH GUPTA" <akhilesh(dot)davim(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: pgcrypto-crypt
Date: 2006-04-06 08:23:26
Message-ID: ad39daf90604060123s7972677cx95c852a59caf94fd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-sql

dear all,
i want to encrypt and decrypt one of the fields in my table (i.e-passwordfield)
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
--
Thanks & Regards,
Akhilesh
DAV Institute of Management
Faridabad(Haryana)
GSM:-(+919891606064)
(+911744293789)

"FAILURES CAN BE FORGIVEN BUT AIMING LOW IS A CRIME"


From: "chris smith" <dmagick(at)gmail(dot)com>
To: "AKHILESH GUPTA" <akhilesh(dot)davim(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: pgcrypto-crypt
Date: 2006-04-06 08:53:17
Message-ID: 3c1395330604060153p4d773e0fu574a190de1fa4d9a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-sql

On 4/6/06, AKHILESH GUPTA <akhilesh(dot)davim(at)gmail(dot)com> 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.....

The crypt function can't be decrypted (whether it's in postgresql or
anywhere else).

Crypt is meant to be used for passwords and such that you don't need
to reverse (you only compare against).

--
Postgresql & php tutorials
http://www.designmagick.com/


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
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.


From: Chris <dmagick(at)gmail(dot)com>
To: AKHILESH GUPTA <akhilesh(dot)davim(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: pgcrypto-crypt
Date: 2006-04-06 22:24:32
Message-ID: 44359520.2060407@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-sql

AKHILESH GUPTA wrote:
> how do we compare the existing data in the table with the entered one?

same way as anything else, for example:

select * from users where passwd=md5('my_password');

> is there any other function which we can use here for both cases
> encryption as well as for decryption at the script as well as database
> level....

why do you need it encrypted?

Please do reply-all - you will get a quicker response (from me and the
list(s) might have suggestions I don't).

> On 4/6/06, *chris smith* <dmagick(at)gmail(dot)com <mailto:dmagick(at)gmail(dot)com>>
> wrote:
>
> On 4/6/06, AKHILESH GUPTA <akhilesh(dot)davim(at)gmail(dot)com
> <mailto:akhilesh(dot)davim(at)gmail(dot)com>> 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.....
>
> The crypt function can't be decrypted (whether it's in postgresql or
> anywhere else).
>
> Crypt is meant to be used for passwords and such that you don't need
> to reverse (you only compare against).
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
>
>
> --
> Thanks & Regards,
> Akhilesh
> DAV Institute of Management
> Faridabad(Haryana)
> GSM:-(+919891606064)
> (+911744293789)
>
> "FAILURES CAN BE FORGIVEN BUT AIMING LOW IS A CRIME"

--
Postgresql & php tutorials
http://www.designmagick.com/