Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQN5z-0000bS-PY for pgsql-interfaces@arkaria.postgresql.org; Wed, 19 Mar 2014 20:28:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WQN5y-0002Rf-MO for pgsql-interfaces@arkaria.postgresql.org; Wed, 19 Mar 2014 20:28:14 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQN5x-0002RY-Gz for pgsql-interfaces@postgresql.org; Wed, 19 Mar 2014 20:28:13 +0000 Received: from albireo.enyo.de ([46.237.207.196]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQN5u-0002ML-5A for pgsql-interfaces@postgresql.org; Wed, 19 Mar 2014 20:28:12 +0000 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) id 1WQN5x-0000dI-0F; Wed, 19 Mar 2014 21:28:13 +0100 Received: from fw by deneb.enyo.de with local (Exim 4.80) (envelope-from ) id 1WQN5r-00029e-D5; Wed, 19 Mar 2014 21:28:07 +0100 From: Florian Weimer To: Karthik Segpi Cc: pgsql-interfaces@postgresql.org Subject: Re: PQunescapebytea not reverse of PQescapebytea? References: Date: Wed, 19 Mar 2014 21:28:07 +0100 In-Reply-To: (Karthik Segpi's message of "Thu, 27 Feb 2014 08:17:29 -0500") Message-ID: <87bnx20w88.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-interfaces Precedence: bulk Sender: pgsql-interfaces-owner@postgresql.org * Karthik Segpi: > I have a 'bytea' column in the database, onto which my custom C applicati= on > is inserting encrypted data. Before inserting, I am calling > 'PQescapebytea()' to escape the ciphertext. However, after SELECT, the da= ta > 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=E2=80=94not everyone uses the \x hexadecimal encoding. --=20 Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-interfaces