pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgcrypto-crypt
5+ messages / 5 participants
[nested] [flat]

* pgcrypto-crypt
@ 2006-04-06 08:23  AKHILESH GUPTA <akhilesh.davim@gmail.com>
  0 siblings, 2 replies; 5+ messages in thread

From: AKHILESH GUPTA @ 2006-04-06 08:23 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; 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"

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgcrypto-crypt
@ 2006-04-06 08:53  chris smith <dmagick@gmail.com>
  parent: AKHILESH GUPTA <akhilesh.davim@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: chris smith @ 2006-04-06 08:53 UTC (permalink / raw)
  To: AKHILESH GUPTA <akhilesh.davim@gmail.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

On 4/6/06, AKHILESH GUPTA <akhilesh.davim@gmail.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/



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgcrypto-crypt
@ 2006-04-06 18:23  Guy Fraser <guy@incentre.net>
  parent: AKHILESH GUPTA <akhilesh.davim@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Guy Fraser @ 2006-04-06 18:23 UTC (permalink / raw)
  To: 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.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgcrypto-crypt
@ 2006-04-06 18:31  Owen Jacobson <ojacobson@osl.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Owen Jacobson @ 2006-04-06 18:31 UTC (permalink / raw)
  To: pgsql-sql

Guy Fraser wrote:
 
> 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'));
> 
> 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.

This works perfectly.



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgcrypto-crypt
@ 2006-04-06 22:24  Chris <dmagick@gmail.com>
  parent: chris smith <dmagick@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Chris @ 2006-04-06 22:24 UTC (permalink / raw)
  To: AKHILESH GUPTA <akhilesh.davim@gmail.com>; +Cc: pgsql-general@postgresql.org; 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@gmail.com <mailto:dmagick@gmail.com>> 
> wrote:
> 
>     On 4/6/06, AKHILESH GUPTA <akhilesh.davim@gmail.com
>     <mailto:akhilesh.davim@gmail.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/



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2006-04-06 22:24 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-04-06 08:23 pgcrypto-crypt AKHILESH GUPTA <akhilesh.davim@gmail.com>
2006-04-06 08:53 ` chris smith <dmagick@gmail.com>
2006-04-06 22:24   ` Chris <dmagick@gmail.com>
2006-04-06 18:23 ` Guy Fraser <guy@incentre.net>
2006-04-06 18:31 Re: pgcrypto-crypt Owen Jacobson <ojacobson@osl.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox