| From: | Erik Wienhold <ewie(at)ewie(dot)name> |
|---|---|
| To: | howardnews(at)selestial(dot)com, Pgsql General <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Playing with pgcrypto |
| Date: | 2022-10-10 22:52:27 |
| Message-ID: | 1927905082.230328.1665442347383@office.mailbox.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi Howard,
> On 11/10/2022 00:25 CEST howardnews(at)selestial(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | howardnews | 2022-10-10 23:17:45 | Re: Playing with pgcrypto |
| Previous Message | howardnews | 2022-10-10 22:25:20 | Playing with pgcrypto |