Re: Storing encrypted data? - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: Storing encrypted data?
Date
Msg-id 20060717030705.GA87022@winnie.fuhr.org
Whole thread Raw
In response to Storing encrypted data?  (John Tregea <john@debraneys.com>)
Responses Re: Storing encrypted data?  (John Tregea <john@debraneys.com>)
List pgsql-sql
On Mon, Jul 17, 2006 at 09:11:12AM +0800, John Tregea wrote:
> Does anyone have experience with storing encrypted data into pgSQL? I 
> have a pgSQL database which uses UTF8 encoding. I am encrypting plain 
> text in my (GUI) application and sending it to a field (with data type 
> 'text') in my database.
> 
> I get an error back saying "invalid byte sequence for encoding UTF8; oxd733"

Use bytea instead of text for binary data; alternatively, base64
encode ("armor") the encrypted data and store it as text.  If you
insert binary data then you'll need to escape non-printable characters
or use an API that can pass binary data to the backend (e.g., libpq's
PQexecParams() or some language's interface to that function).  Some
APIs might automatically escape data if you use placeholders; check
your API's documentation.

http://www.postgresql.org/docs/8.1/interactive/datatype-binary.html
http://www.postgresql.org/docs/8.1/interactive/libpq-exec.html

-- 
Michael Fuhr


pgsql-sql by date:

Previous
From: John Tregea
Date:
Subject: Storing encrypted data?
Next
From: John Tregea
Date:
Subject: Re: Storing encrypted data?