From: Erik Wienhold <ewie@ewie.name>
To: howardnews@selestial.com, Pgsql General <pgsql-general@lists.postgresql.org>
Subject: Re: Playing with pgcrypto
Date: Tue, 11 Oct 2022 00:52:27 +0200 (CEST)
Message-ID: <1927905082.230328.1665442347383@office.mailbox.org> (raw)
In-Reply-To: <21bd2e636ddba3214539cf26243d6708@selestial.com>
References: <21bd2e636ddba3214539cf26243d6708@selestial.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ewie@ewie.name
Subject: Re: Playing with pgcrypto
In-Reply-To: <1927905082.230328.1665442347383@office.mailbox.org>
References: <21bd2e636ddba3214539cf26243d6708@selestial.com> <1927905082.230328.1665442347383@office.mailbox.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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