PQunescapebytea not reverse of PQescapebytea? - Mailing list pgsql-general

From Karthik Segpi
Subject PQunescapebytea not reverse of PQescapebytea?
Date
Msg-id CACD7L9FTet=B=DFwLO1SgaNNukeK6poVxLm524zHtBcmac6ttg@mail.gmail.com
Whole thread Raw
Responses Re: PQunescapebytea not reverse of PQescapebytea?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi -
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.

Is there another C method out there that does exact inverse of
'PQescapebytea'? If the answer is no, then what other options do I have? I
could think of the following:

1. Write my own C method that does exactly the inverse of 'PQescapebytea'
2. Instead of using 'PQescapebytea', base64 encode ciphertext before
inserting. Not sure how well this would work.
3.  Use 'text' data type for the column instead of 'bytea'.

Has anyone faced this scenario before?

Thanks-
Karthik

pgsql-general by date:

Previous
From: "George Weaver"
Date:
Subject: Re: Replacing Ordinal Suffixes
Next
From: Steve Atkins
Date:
Subject: Re: Replacing Ordinal Suffixes