I'm using Ubuntu Server 10.10 and I have installed PostgreSQL 8.4 using apt-get install postgresql
. I would like to use the built-in sha1()
function, but it seems that I have to install pgcrypto
first. But I don't know how to install it.
There is no pgcrypto
if I try to install it using apt-get install pgcrypto
and I don't find any files starting with pgcrypto
in my system (I tried find / -name "pgcrypto*"
).
How do I install pgcrypto so I can use the digest('word-to-hash','sha1')
function in my database queries?
Update: I'm struggling to install pgcrypto on another Ubuntu machine. After installing the package using sudo apt-get install postgresql-contrib-8.4
how do I install it to my current PostgreSQL database?
Best Answer
For newer version of PG, check out the answer below by Dustin Kirkland
It's an external module for Postgres. You should install the
postgresql-contrib-8.4
(or your pg version) package via apt:Then you find the sql install file somewhere in the
/usr/share/postgresql
folder, and you'll need to runpgcryto.sql
on the database.Or,