X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7FBCE52967 for ; Thu, 11 Aug 2005 18:26:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53675-09 for ; Thu, 11 Aug 2005 21:26:17 +0000 (GMT) Received: from sapo.pt (relay5.ptmail.sapo.pt [212.55.154.25]) by svr1.postgresql.org (Postfix) with SMTP id 71CD652943 for ; Thu, 11 Aug 2005 18:26:15 -0300 (ADT) Received: (qmail 23727 invoked from network); 11 Aug 2005 21:26:13 -0000 Received: from unknown (HELO sapo.pt) (10.134.35.207) by relay5 with SMTP; 11 Aug 2005 21:26:13 -0000 Received: (qmail 786 invoked from network); 11 Aug 2005 21:26:13 -0000 X-AntiVirus: PTMail-AV 0.3-0.86.2 Received: from unknown (HELO hmv02) ([82.155.149.78]) (envelope-sender ) by mta12 (qmail-ldap-1.03) with SMTP for ; 11 Aug 2005 21:26:13 -0000 Message-ID: <000d01c59ebb$4d611c50$580bfea9@hmv02> From: =?iso-8859-1?Q?H=E9lder_M._Vieira?= To: References: <20050811203922.84270.qmail@web50602.mail.yahoo.com> Subject: Re: Fwd: How to encrypt a column Date: Thu, 11 Aug 2005 22:26:13 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.508 tagged_above=0 required=5 tests=[AWL=-0.292, DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, FORGED_RCVD_HELO=0.05] X-Spam-Level: * X-Archive-Number: 200508/59 X-Sequence-Number: 22287 >I'm interested in encrypting an column in table. Are there any example >using "C" to create the encrypted column, inserting and retreiving data >to/from it? >the table is: >CREATE TABLE mytable ( > id SERIAL PRIMARY KEY, > crypted_content BYTEA ); >I'm getting (null) in the field with the following sql statement: >strcpy(data, "data to be encrypted"); >sprintf(query_buff, "insert into mytable values('%s', '%s')", key, >encrypt(data, 'foo', 'bar')); >PQexec(conn, query_string); >Another question is can the encrypted column be of type "text" ? I'd check a previous critical point ... The encrypt() function output. What is the range of characters in encrypt() output ? Control, null or false escape characters, if not properly escaped, could be misleading either sprintf or the query processor in pg. Helder M. Vieira