Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I'm trying to just hash some passwords in postgresql, and the only hashing solution that I've found for postgresql is part of the pgcrytpo package ( ) that is supposed to be in postgresql-contrib ( ).

So I installed postgresql-contrib, (sudo apt-get install postgresql-contrib), restarted my server (as a simple way to restart postgresql).

However, I still don't have access to any of the functions for hashing that are supposed to be in postgresql-contrib, e.g.:

ninjawars=# select crypt('global salt' || 'new password' || 'user created date', gen_salt('sha256'));
ERROR:  function gen_salt(unknown) does not exist

ninjawars=# select digest('test', 'sha256') from players limit 1;
ERROR:  function digest(unknown, unknown) does not exist

ninjawars=# select hmac('test', 'sha256') from players limit 1;
ERROR:  function hmac(unknown, unknown) does not exist

So how can I hash passwords in postgresql, on ubuntu?

share|improve this question
up vote 4 down vote accepted

This may be a hint, from one of the web pages you listed above:

Many modules supply new user-defined functions, operators, or types. To make use of one of these modules, after you have installed the code you need to register the new objects in the database system by running the SQL commands in the .sql file supplied by the module. For example,

psql -d dbname -f SHAREDIR/contrib/module.sql
share|improve this answer
Gracias, that does explain it. – Kzqai Apr 15 '10 at 21:27

After you install postgresql-contrib you need to run CREATE EXTENSION pgcrypto; against the db where you want to use the crypto functions

share|improve this answer
Although pgcrypto looks like already installed, it needs to be installed again. Strange. But it helped me, 10x. – Pavel Vlasov Mar 2 '15 at 12:50
yes, it has to be enabled for each db you want to use it on – Anentropic Mar 3 '15 at 13:49

Much easier Just install pdAdmin and from the database you are working on right click on the database and ADD NEW OBJECT select Extension then select pgcrypto for name and set the definition schema to public and version 1.0 WORKED AS A CHARM FOR ME ON MY MAC OS 10.7.5 using Postgres 9.2

share|improve this answer
Yeah, they seem to have updated the system to make extensions easier to manage, happily, and now after installing postgresql-contrib in postgres 9.1 and up you can just: create extension pgcrypto or from the command line echo "create extension pgcrypto" | psql -d dataBaseName to enable extensions, as well. – Kzqai Nov 13 '12 at 20:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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