Thread: Pgcrypto extension - decrypt(encrypt(... not returning original data?
I tried to use the pgcrypto extension.
from the manual.
there are two functions - encrypt and decrypt - signatures as follows.
encrypt(data bytea, key bytea, type text) returns bytea decrypt(data bytea, key bytea, type text) returns bytea
OK.
I try to run this -- see a fiddle
SELECT
encrypt('da'::BYTEA, 'pw'::BYTEA, 'bf'),
pg_typeof(encrypt('da'::BYTEA, 'pw'::BYTEA, 'bf')),
decrypt(encrypt('da'::BYTEA, 'pw'::BYTEA, 'bf'), 'pw', 'bf');
but I get this as my result.
encrypt | pg_typeof | decrypt |
---|---|---|
\x54027d78b34ac951 | bytea | \x6461 |
Why is my decrypt function not return the string 'da'? Have I not understand something important?
SQLP!
hex 2 ascii SQL Padawan schreef op wo 01-12-2021 om 18:37 [+0000]: > \x6461 -- mvg, Wim Bertels -- https://coronalert.be Lector UC Leuven-Limburg -- Truth is the most valuable thing we have -- so let us economize it. -- Mark Twain
SQL Padawan <sql_padawan@protonmail.com> writes: > Why is my decrypt function not return the string 'da'? Have I not understand something important? See the bytea_output setting. regards, tom lane