In Linux (with Ubuntu or Debian) if I want to install gen_salt(), I first install the -contrib package.

sudo apt install postgresql-contrib

Then I install the extension in the database,

psql -d myDatabase -c "create extension pgcrypto"

How do I get gen_salt() and crypt() working in Windows?

  • The pg_crypto and gen_salt functionality is not working in Postgres Windows. It has to be enabled so as to store a encypted password. Any idea, how it is possible? – saifahmed Sep 26 '18 at 13:26
  • 1
    So what's the error message you get? And what is the exact command you used to create the extension? And what is your exact Postgres version? edit your question by clicking on the edit link below it. Do not post code or additional information in comments – a_horse_with_no_name Sep 26 '18 at 13:30
  • If you're having a problem with pgcrypto specifically, please ask another question related to just that. Posting the exact problem you're experiencing. – Evan Carroll Sep 26 '18 at 16:15

The equivalent:

Login in postgresql, connect on the database you are having problem then issue:

create extension pgcrypto;

Is that.


In Windows, the installer used wasn't provided by PostgreSQL, but instead by one of their third party providers. Usually these third parties bundle by default the -contrib modules that would be packaged and installed independently on Linux distros. This is in part because Windows lacks a system to tie into and provide additional abilities like apt or dnf.

Because the installer provided the extension, all you have to do is run CREATE EXTENSION pgcrypto; to tie it into the database.

psql -d myDatabase -c "CREATE EXTENSION pgcrypto;"

Or connect to the database and run

  • CREATE EXTENSION pgcrypto; --------------------------------------------- thanks, it worked for me . – saifahmed Sep 28 '18 at 6:51
  • Can I ask for example how to install pglogical on Windows? i'm searching for solution for 2 days I didn't find where to start exactly. – Charif DZ Dec 14 '19 at 9:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.