Problems with pgcrypto and special characters

From: "Markus Wollny" <Markus(dot)Wollny(at)computec(dot)de>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Problems with pgcrypto and special characters
Date: 2005-02-28 17:32:41
Message-ID: 2266D0630E43BB4290742247C89105750716F8E4@dozer.computec.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 decrypt text which contains UTF-8 special characters like german umlauts? I think that this simple bytea2text-function probably needs a replacement, but I haven't got the faintest clue about how to actually retrieve the original input after encryption. Any help would be tremendously appreciated :)

Thanks in advance!

Kind regards

Markus

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-02-28 18:08:59 Re: [GENERAL] Newbie - Pointers on moving.
Previous Message Steffen Boehme 2005-02-28 17:26:36 Performance of Views