1. Knowledge Base
  2. Admin
  3. Database Administration

How do I install pgcrypto?

If you are going to use credit card processing or if you're getting this message ERROR:  function decrypt(bytea, bytea, unknown) does not exist then you need to install pgcrypto. Pgcrypto is a library used for encrypting sensitive data. The pgcrypto software is a popular add-on package included with the PostgreSQL source code distribution. The pgcrypto module is used by our credit card encryption functionality.  Even if you are not processing credit cards, we still recommend that pgcrypto be installed. 

First, we need to locate the pgcrypto.sql file.  One typical path to this is:


If it isn't there you can always search for the file.  You may need to perform the search as root (be patient, this takes a while):

find / | grep pgcrypto.sql

Or if you're on Windows just use the Windows file search.

Once you've located the file the next step is to install it.  The command to install pgcrypto onto your database is:

psql -U mfgadmin NameOfDB < /wherever/the/file/is/pgcrypto.sql 

Or if you prefer using pgAdmin, connect to the database you want to install pgcrypto and open/execute pgcrypto.sql through the SQL Editor.  It is also a good idea to install pgcrypto.sql on the template1 database.