X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 19E6C9FA326 for ; Thu, 18 May 2006 23:55:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 50376-02 for ; Thu, 18 May 2006 23:55:43 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web30404.mail.mud.yahoo.com (web30404.mail.mud.yahoo.com [68.142.200.107]) by postgresql.org (Postfix) with SMTP id C84109FA1B0 for ; Thu, 18 May 2006 23:55:43 -0300 (ADT) Received: (qmail 9812 invoked by uid 60001); 19 May 2006 02:55:42 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=2icdv8qgy6FQX5xLQUiRi/H7LY1/bnZH/0znjXKZtCcVuuB5AZHlxQ6RVelesKMTZWTp6dnvlAAa85oQC08UdwQH9Var6ATnwq1yj8Gq97VPWf8CKdl+vR/btGlPcNuMAw69eMLMJP2a1LtIpD2Zx9LIic3C5O5fIBonVqtOnA4= ; Message-ID: <20060519025542.9810.qmail@web30404.mail.mud.yahoo.com> Received: from [203.115.30.220] by web30404.mail.mud.yahoo.com via HTTP; Thu, 18 May 2006 19:55:42 PDT Date: Thu, 18 May 2006 19:55:42 -0700 (PDT) From: Thusitha Kodikara Subject: Re: Encryption functions To: "D'Arcy J.M. Cain" , Michael Fuhr Cc: kthusi@yahoo.com, pgsql-sql@postgresql.org In-Reply-To: <20060518091339.249bf054.darcy@druid.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1558075085-1148007342=:9791" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/150 X-Sequence-Number: 25181 --0-1558075085-1148007342=:9791 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Thanks for the guidance . -Thusitha "D'Arcy J.M. Cain" wrote: On Thu, 18 May 2006 06:44:55 -0600 Michael Fuhr 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 | 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. ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq --0-1558075085-1148007342=:9791 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Thanks for the guidance .

-Thusitha

"D'Arcy J.M. Cain" <darcy@druid.net> wrote:
On Thu, 18 May 2006 06:44:55 -0600
Michael Fuhr 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 | 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.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

--0-1558075085-1148007342=:9791--