From: | SQL Padawan <sql_padawan(at)protonmail(dot)com> |
---|---|
To: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Pgcrypto extension - decrypt(encrypt(... not returning original data? |
Date: | 2021-12-01 18:37:37 |
Message-ID: | J8xQH_zNR9gNuRimbKUbEyEOarp51EazTCo4agf1xvWnLoQuiSCOhQ34uRzWz__AMWo1_Hw4xcb-SCMRf5-V_ZPc949iuZRIqQ0ODfeegnE=@protonmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I tried to use the pgcrypto extension.
from the manual.
https://www.postgresql.org/docs/14/pgcrypto.html
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
https://dbfiddle.uk/?rdbms=postgres_13&fiddle=d2c102f5fb6e62acb1c70a2dc755fdca
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!
From | Date | Subject | |
---|---|---|---|
Next Message | Wim Bertels | 2021-12-01 18:51:19 | Re: Pgcrypto extension - decrypt(encrypt(... not returning original data? |
Previous Message | SQL Padawan | 2021-12-01 18:22:40 | Re: Database Scalability |