Re: Pgcrypto install (I've tried multiple ways) - Mailing list pgsql-novice

From David Patricola
Subject Re: Pgcrypto install (I've tried multiple ways)
Date
Msg-id 5ADE6D6F2A5146309A2BD76E6B1D2D3E@tjumst.jefferson.edu
Whole thread Raw
In response to Re: Pgcrypto install (I've tried multiple ways)  (Michael Wood <esiotrot@gmail.com>)
List pgsql-novice
This put me on the right track, and I did find a solution.

select encode(decrypt(testfield2, 'key', 'aes'), 'escape') AS foo from table

I needed to add encode() when outputting to the browser (using ColdFusion),
but converting the field to bytea did the trick.  Thanks to both of you!

-----Original Message-----
From: Michael Wood [mailto:esiotrot@gmail.com]
Sent: Friday, January 28, 2011 8:56 AM
To: David Patricola
Cc: Tom Lane; pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Pgcrypto install (I've tried multiple ways)

On 28 January 2011 02:06, David Patricola <david.patricola@jefferson.edu>
wrote:
> What I have to do is store multiple fields encrypted from user input, them
> decrypt them for retrieval to the browser.  Is there a preferred way to do
> this?

Try creating a column with type "bytea" and store the results of the
encrypt() in there.  Then use that column with decrypt().  (Or alter
the type of your existing "thenotes" column from varchar to bytea.)

See also:

http://www.postgresql.org/docs/9.0/static/datatype-binary.html

Note: I've never used pgcrypt.

--
Michael Wood <esiotrot@gmail.com>


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Set default time zone for displaying dates in a session
Next
From: "ljochoa3@cantv.net"
Date:
Subject: ljochoa3@cantv.net