Re: PQunescapebytea not reverse of PQescapebytea?

From: Florian Weimer <fw(at)deneb(dot)enyo(dot)de>
To: Karthik Segpi <karthik(dot)segpi(at)gmail(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: PQunescapebytea not reverse of PQescapebytea?
Date: 2014-03-19 20:28:07
Message-ID: 87bnx20w88.fsf@mid.deneb.enyo.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

* Karthik Segpi:

> I have a 'bytea' column in the database, onto which my custom C application
> is inserting encrypted data. Before inserting, I am calling
> 'PQescapebytea()' to escape the ciphertext. However, after SELECT, the data
> needs to be 'un-escaped' before attempting to decrypt. I am trying to
> 'un-escape' using 'PQunescapebytea'. However, I am finding that
> 'PQunescapebytea' is not exact inverse of 'PQescapebytea'. I saw
> documentation and posts in the mailing lists alluding to this as well. As a
> result, the decryption always fails.

Can you show us some example data that shows the inconsistency?
PQunescapebytea should give you back the blob you passed to
PQescapebytea, but the same blob can have different BYTEA
encodings—not everyone uses the \x hexadecimal encoding.

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jeff Davis 2014-03-26 04:19:58 Re: PQunescapebytea not reverse of PQescapebytea?
Previous Message David Wall 2014-03-11 22:37:46 Re: Which Java class in the new java.time package shall be used to mapped timestamp?