Problems with pgcrypto and special characters - Mailing list pgsql-general

From Markus Wollny
Subject Problems with pgcrypto and special characters
Date
Msg-id 2266D0630E43BB4290742247C89105750716F8E4@dozer.computec.de
Whole thread Raw
Responses Re: Problems with pgcrypto and special characters
Re: Problems with pgcrypto and special characters
List pgsql-general
Hello!

To get straight to the point, here's my problem:

mypgdb=# select bytea2text(decrypt(encrypt('Tübingen'::bytea,
'mypassphrase'::bytea,'bf'::text),'mypassphrase'::bytea,'bf'::text))as foo; 
       foo
-----------------
 T\303\274bingen
(1 row)

I have compiled and installed pg_crypto and I'am using the following function as workaround for a bytea-to-text-cast:

create or replace function bytea2text(bytea) returns text as '
 begin
   return $1;
 end;
 ' language plpgsql;

The cluster was initialized with locale de_DE.UTF-8, pg_controldata confirms:
LC_COLLATE:                           de_DE.UTF-8
LC_CTYPE:                             de_DE.UTF-8

Database version is PostgreSQL 8.0.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2

I think I'm missing something very obvious here, so please give me a hint: How can I use pgcrypto to encrypt and
decrypttext which contains UTF-8 special characters like german umlauts? I think that this simple bytea2text-function
probablyneeds a replacement, but I haven't got the faintest clue about how to actually retrieve the original input
afterencryption. Any help would be tremendously appreciated :) 

Thanks in advance!

Kind regards

   Markus

pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: row numbering
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Possible to run the server with ANSI/ISO string escapeing