pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPlaying with pgcrypto
3+ messages / 2 participants
[nested] [flat]
* Playing with pgcrypto
@ 2022-10-10 22:25 howardnews@selestial.com
0 siblings, 1 reply; 3+ messages in thread
From: howardnews@selestial.com @ 2022-10-10 22:25 UTC (permalink / raw)
To: Pgsql General <pgsql-general@lists.postgresql.org>
Hi all,
I am trying out a few pgcrypto functions. I was expecting the final
select statement to return the row I just inserted - Can anyone tell me
what I am not understanding here?
create table test (p1 bytea);
insert into test (pgp_sym_encrypt('123', 'secret'));
select * from test where pgp_sym_encrypt('123', 'secret') = p1;
Thanks.
Howard
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Playing with pgcrypto
@ 2022-10-10 22:52 Erik Wienhold <ewie@ewie.name>
parent: howardnews@selestial.com
0 siblings, 1 reply; 3+ messages in thread
From: Erik Wienhold @ 2022-10-10 22:52 UTC (permalink / raw)
To: howardnews@selestial.com, Pgsql General <pgsql-general@lists.postgresql.org>
Hi Howard,
> On 11/10/2022 00:25 CEST howardnews@selestial.com wrote:
>
> I am trying out a few pgcrypto functions. I was expecting the final
> select statement to return the row I just inserted - Can anyone tell me
> what I am not understanding here?
>
> create table test (p1 bytea);
> insert into test (pgp_sym_encrypt('123', 'secret'));
Your INSERT is malformed. It's missing a VALUES clause or SELECT.
> select * from test where pgp_sym_encrypt('123', 'secret') = p1;
pgp_sym_encrypt uses a random salt each time, so you cannot compare the output
to p1 like you would do with crypt to verify a given plaintext. Instead, use
pgp_sym_decrypt with p1 as input to get the plaintext.
--
Erik
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Playing with pgcrypto
@ 2022-10-10 23:17 howardnews@selestial.com
parent: Erik Wienhold <ewie@ewie.name>
0 siblings, 0 replies; 3+ messages in thread
From: howardnews@selestial.com @ 2022-10-10 23:17 UTC (permalink / raw)
To: Erik Wienhold <ewie@ewie.name>; +Cc: Pgsql General <pgsql-general@lists.postgresql.org>
> pgp_sym_encrypt uses a random salt each time, so you cannot compare the
> output
> to p1 like you would do with crypt to verify a given plaintext.
> Instead, use
> pgp_sym_decrypt with p1 as input to get the plaintext.
>
> --
> Erik
Ah! That makes sense. Thanks Erik!
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-10-10 23:17 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 22:25 Playing with pgcrypto howardnews@selestial.com
2022-10-10 22:52 ` Erik Wienhold <ewie@ewie.name>
2022-10-10 23:17 ` howardnews@selestial.com
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