Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres pgcrypto privliledges

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.

like image 476
Doo Dah Avatar asked Sep 14 '15 00:09

Doo Dah


People also ask

What is pgcrypto in PostgreSQL?

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

What is privileges in PostgreSQL?

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.

What is the best way to encrypt data in PostgreSQL?

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.

What is the preferred key type for PGP encryption?

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.


1 Answers

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.

like image 169
Sami Kuhmonen Avatar answered Sep 28 '22 05:09

Sami Kuhmonen