incuna / django-pgcrypto-fields

Transparent field level encryption for Django using the pgcrypto postgresql extension.
BSD 2-Clause "Simplified" License
229 stars 49 forks source link

function pgp_pub_decrypt(character varying, bytea) does not exist #595

Open caipirginka opened 8 months ago

caipirginka commented 8 months ago

I'm using:

PostgreSQL 16.0 (Debian 16.0-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
pgcrypto | 1.3     | public     | cryptographic functions

and the function pgp_pub_decrypt(character varying, bytea) does not exist, it is not even listed in the documentation of pgcrypto itself: https://www.postgresql.org/docs/current/pgcrypto.html

To make everything work, I have to create it, like this:

    CREATE FUNCTION pgp_pub_decrypt(
        msg character varying,
        key bytea)
      RETURNS text AS 
    $$
        select pgp_pub_decrypt(msg::bytea,key)
    $$ LANGUAGE SQL;

Is this workaround correct?