agora inbox for pgsql-interfaces@postgresql.org  
help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: Karthik Segpi <karthik.segpi@gmail.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: PQunescapebytea not reverse of PQescapebytea?
Date: Wed, 19 Mar 2014 21:28:07 +0100
Message-ID: <87bnx20w88.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <CACD7L9GCLsM=wEwwH707sN19dMkMHwHh+ffVmLQdsFXNR0UJ6Q@mail.gmail.com>
References: <CACD7L9GCLsM=wEwwH707sN19dMkMHwHh+ffVmLQdsFXNR0UJ6Q@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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.


-- 
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces



view thread (4+ messages)  latest in thread

Message-ID: <87bnx20w88.fsf@mid.deneb.enyo.de>
Permalink:  ../87bnx20w88.fsf@mid.deneb.enyo.de/
Also on:    postgresql.org/message-id/87bnx20w88.fsf@mid.deneb.enyo.de

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: fw@deneb.enyo.de, karthik.segpi@gmail.com
  Subject: Re: PQunescapebytea not reverse of PQescapebytea?
  In-Reply-To: <87bnx20w88.fsf@mid.deneb.enyo.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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