I am using postgresql v13.2 andlooking to replace importing the bcrypt package with using pgcrypto and 'bf'alogithm.
The attached is using pgAdmin
I get the error ERROR: function gen_salt(unknown) does not exist
The installed pgcrypto version is 1.3
Test table:
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
password TEXT NOT NULL
);
Example code:
INSERT INTO users (email, password) VALUES (
'[email protected]',
crypt('johnspassword', gen_salt('bf'))
);
Error message: ERROR: function gen_salt(unknown) does not exist LINE 3: crypt('johnspassword', gen_salt('bf')) ); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. SQL state: 42883 Character: 95
You have to enable the crypto function
CREATE TABLE users ( id SERIAL PRIMARY KEY, email TEXT NOT NULL UNIQUE, password TEXT NOT NULL );
INSERT INTO users (email, password) VALUES ( '[email protected]', crypt('johnspassword', gen_salt('bf')) );
ERROR: function gen_salt(unknown) does not exist
LINE 3: crypt('johnspassword', gen_salt('bf'))
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
CREATE EXTENSION pgcrypto;
INSERT INTO users (email, password) VALUES ( '[email protected]', crypt('johnspassword', gen_salt('bf')) );
1 rows affected
db<>fiddle here
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