pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: D'Arcy J.M. Cain <darcy@druid.net>
To: Michael Fuhr <mike@fuhr.org>
Cc: kthusi@yahoo.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Encryption functions
Date: Thu, 18 May 2006 09:13:39 -0400
Message-ID: <20060518091339.249bf054.darcy@druid.net> (raw)
In-Reply-To: <20060518124455.GA8583@winnie.fuhr.org>
References: <20060518112119.85801.qmail@web30406.mail.mud.yahoo.com>
	<20060518124455.GA8583@winnie.fuhr.org>

On Thu, 18 May 2006 06:44:55 -0600
Michael Fuhr <mike@fuhr.org> wrote:

> On Thu, May 18, 2006 at 04:21:19AM -0700, Thusitha Kodikara wrote:
> > Are there any encryption functions that can be used in
> > SQL inserts and selects directly?  For example like
> > "select encryptin_function('test_to_be_encrypted'), ........"
> 
> See the contrib/pgcrypto module.  It has functions like digest()
> for making SHA1, MD5, and other digests; hmac() for making Hashed
> Message Authentication Codes; and encrypt()/encrypt_iv() and
> decrypt()/decrypt_iv() for doing encryption and decryption.  Since
> 8.1 pgcrypto also has functions for doing OpenPGP symmetric and
> public-key encryption.

If your requirements are simpler check out the genpass module.  It is a
DES3 encrypted type.  You can do things like "SELECT * FROM table WHERE
passw = 'hello'" and it will find passwords that are entered as 'hello'
even though they are stored encrypted.  Example:

darcy=# select 'hello'::chkpass;
    chkpass
----------------
 :v1L3NdWy0OHlQ
(1 row)

darcy=# select ':v1L3NdWy0OHlQ'::chkpass = 'hello';
 ?column?
----------
 t
(1 row)

darcy=# select ':v1L3NdWy0OHlQ'::chkpass = 'nothello';
 ?column?
----------
 f
(1 row)

Note that the leading colon says that the string is already encrypted.
This allows dump and restore to work correctly.

-- 
D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



view thread (6+ messages)  latest in thread

Message-ID: <20060518091339.249bf054.darcy@druid.net>
Permalink:  ../20060518091339.249bf054.darcy@druid.net/
Also on:    postgresql.org/message-id/20060518091339.249bf054.darcy@druid.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: darcy@druid.net, mike@fuhr.org, kthusi@yahoo.com
  Subject: Re: Encryption functions
  In-Reply-To: <20060518091339.249bf054.darcy@druid.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox