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?

closed as unclear what you're asking by mustaccio, hot2use, a_horse_with_no_name, Colin 't Hart, Md Haidar Ali Khan Sep 27 '18 at 3:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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

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