From: | "Markus Wollny" <Markus(dot)Wollny(at)computec(dot)de> |
---|---|
To: | Ragnar Hafstað <gnari(at)simnet(dot)is> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Problems with pgcrypto and special characters |
Date: | 2005-02-28 20:54:42 |
Message-ID: | 2266D0630E43BB4290742247C891057502B9D6E2@dozer.computec.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
-----Original Message-----
From: Ragnar Hafstað [mailto:gnari(at)simnet(dot)is]
>are you sure your problem is with pg_crypto ?
>what does this produce:
> select bytea2text('Tübingen'::bytea) as foo;
>?
Well I'm sure it's not WITH pgcrypto but with actually using pgcrypto in conjunction with UTF-8 encoded text. This function doesn't do anything but replace a bytea::text-cast.
>have you tried to use encode()/decode() instead ?
>untested:
> select
> decode(
> decrypt(
> encrypt(
> encode('Tübingen','escape') ,
> 'mypassphrase'::bytea,
> 'bf'::text
> ),
> 'mypassphrase'::bytea,
> 'bf'::text
> )
> ) as foo;
Yes, and that doesn't work either:
mypgdb=# select decode(encode('Tübingen'::text::bytea,'escape'),'escape');
decode
-----------------
T\303\274bingen
(1 row)
But I just found the bugger - we both confused encode and decode :)
mypgdb=# select encode(decode('Tübingen','escape'),'escape');
encode
----------
Tübingen
(1 row)
Now using pgcrypto works, too:
mypgdb=# select encode(decrypt(encrypt(decode('Tübingen'::text,'escape'),'mypassphrase','bf'),'mypassphrase','bf'),'escape');
encode
----------
Tübingen
(1 row)
Thanks nevertheless, this was exactly the push in the right direction that I needed!
Kind regards
Markus
From | Date | Subject | |
---|---|---|---|
Next Message | Markus Wollny | 2005-02-28 21:00:32 | Re: Problems with pgcrypto and special characters |
Previous Message | Jeff Davis | 2005-02-28 20:53:01 | Re: Possible to run the server with ANSI/ISO string |