From: | "Owen Jacobson" <ojacobson(at)osl(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: pgcrypto-crypt |
Date: | 2006-04-06 18:31:41 |
Message-ID: | 144D12D7DD4EC04F99241498BB4EEDCC2883A8@nelson.osl.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Judith | 2006-04-06 18:37:24 | Query from shell |
Previous Message | Guy Fraser | 2006-04-06 18:23:27 | Re: pgcrypto-crypt |