pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPgcrypto extension - decrypt(encrypt(... not returning original data?
3+ messages / 3 participants
[nested] [flat]
* Pgcrypto extension - decrypt(encrypt(... not returning original data?
@ 2021-12-01 18:37 SQL Padawan <sql_padawan@protonmail.com>
2021-12-01 18:51 ` Re: Pgcrypto extension - decrypt(encrypt(... not returning original data? Wim Bertels <wim.bertels@ucll.be>
2021-12-01 18:51 ` Re: Pgcrypto extension - decrypt(encrypt(... not returning original data? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 3+ messages in thread
From: SQL Padawan @ 2021-12-01 18:37 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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!
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Pgcrypto extension - decrypt(encrypt(... not returning original data?
2021-12-01 18:37 Pgcrypto extension - decrypt(encrypt(... not returning original data? SQL Padawan <sql_padawan@protonmail.com>
@ 2021-12-01 18:51 ` Wim Bertels <wim.bertels@ucll.be>
1 sibling, 0 replies; 3+ messages in thread
From: Wim Bertels @ 2021-12-01 18:51 UTC (permalink / raw)
To: SQL Padawan <sql_padawan@protonmail.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Pgcrypto extension - decrypt(encrypt(... not returning original data?
2021-12-01 18:37 Pgcrypto extension - decrypt(encrypt(... not returning original data? SQL Padawan <sql_padawan@protonmail.com>
@ 2021-12-01 18:51 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2021-12-01 18:51 UTC (permalink / raw)
To: SQL Padawan <sql_padawan@protonmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2021-12-01 18:51 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01 18:37 Pgcrypto extension - decrypt(encrypt(... not returning original data? SQL Padawan <sql_padawan@protonmail.com>
2021-12-01 18:51 ` Wim Bertels <wim.bertels@ucll.be>
2021-12-01 18:51 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox