I intsalled the pgcrypto extension as the superuser like this:
CREATE EXTENSION pgcrypto;
As the superuser, I tested it, and it works find:
select gen_salt('bf');
gen_salt
-------------------------------
$2a$06$CJPcLcOBZnCEl.Z5ChrSbO
But, when logging in as a different user, I get an error as follows:
select gen_salt('bf');
ERROR: function gen_salt(unknown) does not exist
How do I make the pgcrypto library visible to all users?
Thanks.
The pgcrypto module provides cryptographic functions for PostgreSQL. This module is considered “trusted”, that is, it can be installed by non-superusers who have CREATE privilege on the current database. F.26.1. General Hashing Functions digest (data text, type text) returns bytea digest (data bytea, type text) returns bytea
PostgreSQL: Documentation: 12: 5.7. Privileges 5.7. Privileges Chapter 5. Data Definition 5.7. Privileges When an object is created, it is assigned an owner. The owner is normally the role that executed the creation statement. For most kinds of objects, the initial state is that only the owner (or a superuser) can do anything with the object.
Normally when people want one way encryption and just want a basic simple level of encryption, they use the md5 function which is built into PostgreSQL by default. The md5 function is equivalent to using the PASSWORD function in MySQL.
The preferred key type is “DSA and Elgamal”. For RSA encryption you must create either DSA or RSA sign-only key as master and then add an RSA encryption subkey with gpg --edit-key. You need to use dearmor () on these keys before giving them to the PGP functions. Or if you can handle binary data, you can drop -a from the command.
PostgreSQL extensions are per database. If you log in to another database, the extension is not available there. By default the functions are usable by any user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With