Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 06F56650054 for ; Tue, 21 Oct 2008 13:03:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 04281-03 for ; Tue, 21 Oct 2008 13:03:37 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from bay0-omc2-s13.bay0.hotmail.com (bay0-omc2-s13.bay0.hotmail.com [65.54.246.149]) by postgresql.org (Postfix) with ESMTP id 2D7E564FF86 for ; Tue, 21 Oct 2008 13:03:37 -0300 (ADT) Received: from hotmail.com ([65.54.162.75]) by bay0-omc2-s13.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 21 Oct 2008 09:03:35 -0700 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 21 Oct 2008 09:03:36 -0700 Message-ID: Received: from 190.3.112.90 by BAY108-DAV3.phx.gbl with DAV; Tue, 21 Oct 2008 16:03:33 +0000 X-Originating-IP: [190.3.112.90] X-Originating-Email: [elmarkivo@hotmail.com] X-Sender: elmarkivo@hotmail.com From: "elmarkivp" To: Subject: store files encrypted with pgcrypto Date: Tue, 21 Oct 2008 14:03:28 -0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0013_01C93385.CB3B7C30" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-OriginalArrivalTime: 21 Oct 2008 16:03:36.0038 (UTC) FILETIME=[92F48860:01C93396] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200810/13 X-Sequence-Number: 3910 This is a multi-part message in MIME format. ------=_NextPart_000_0013_01C93385.CB3B7C30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, i'm trying to store files encrypted in postgres 8.3.4, using = sym_encrypt_bytea function. this is quoted from the postgres8.3 documentation, thats was my guide, = below is the php code i have used to make it, with no results and the = respective errors. FROM http://www.postgresql.org/docs/8.3/static/pgcrypto.html F.20.3.1. pgp_sym_encrypt() pgp_sym_encrypt(data text, psw text [, options text ]) returns bytea pgp_sym_encrypt_bytea(data bytea, psw text [, options text ]) = returns bytea =20 Encrypt data with a symmetric PGP key psw. The options parameter can = contain option settings, as described below. F.20.3.2. pgp_sym_decrypt() pgp_sym_decrypt(msg bytea, psw text [, options text ]) returns text pgp_sym_decrypt_bytea(msg bytea, psw text [, options text ]) returns = bytea =20 Decrypt a symmetric-key-encrypted PGP message. Decrypting bytea data with pgp_sym_decrypt is disallowed. This is to = avoid outputting invalid character data. Decrypting originally textual = data with pgp_sym_decrypt_bytea is fine. The options parameter can contain option settings, as described below.=20 F.20.3.7. Options for PGP functions Options are named to be similar to GnuPG. An option's value should be = given after an equal sign; separate options from each other with commas. = For example: pgp_sym_encrypt(data, psw, 'compress-algo=3D1, = cipher-algo=3Daes256') =20 All of the options except convert-crlf apply only to encrypt functions. = Decrypt functions get the parameters from the PGP data. The most interesting options are probably compress-algo and = unicode-mode. The rest should have reasonable defaults.=20 THIS IS MY CODE.. =20 ERRORS: =20 ERROR: No function matches the given name and argument types. You = might need to add explicit type casts=20 ERROR: function pgp_sym_encrypt_bytea(unknown, integer, unknown) does = not exist=20 =20 OTHER CODE WITH EXPLICIT TYPES =20 ERRORS: ERROR: function pgp_sym_encrypt_bytea(bytea, text, text) does not = exist=20 =20 any help is welcome! =20 =20 ------=_NextPart_000_0013_01C93385.CB3B7C30 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi, i'm trying to store files encrypted = in postgres=20 8.3.4, using sym_encrypt_bytea function.
this is quoted from the = postgres8.3=20 documentation, thats was my guide, below is the php code i have used to = make it,=20 with no results and the respective errors.
 
FROM http://w= ww.postgresql.org/docs/8.3/static/pgcrypto.html
 
F.20.3.1. = pgp_sym_encrypt()
 
    pgp_sym_encrypt(data = text, psw=20 text [, options text ]) returns bytea
   =20 pgp_sym_encrypt_bytea(data bytea, psw text [, options text ]) returns=20 bytea
  
 
Encrypt data with a symmetric PGP key = psw. The=20 options parameter can contain option settings, as described = below.
F.20.3.2.=20 pgp_sym_decrypt()
 
    pgp_sym_decrypt(msg = bytea, psw=20 text [, options text ]) returns text
   =20 pgp_sym_decrypt_bytea(msg bytea, psw text [, options text ]) returns=20 bytea
  
 
Decrypt a symmetric-key-encrypted PGP=20 message.
 
Decrypting bytea data with = pgp_sym_decrypt is=20 disallowed. This is to avoid outputting invalid character data. = Decrypting=20 originally textual data with pgp_sym_decrypt_bytea is fine.
 
The options parameter can contain = option settings,=20 as described below.
 
F.20.3.7. Options for PGP = functions
 
Options are named to be similar to = GnuPG. An=20 option's value should be given after an equal sign; separate options = from each=20 other with commas. For example:
 
    = pgp_sym_encrypt(data, psw,=20 'compress-algo=3D1, cipher-algo=3Daes256')
  
 
All of the options except convert-crlf = apply only=20 to encrypt functions. Decrypt functions get the parameters from the PGP=20 data.
 
The most interesting options are = probably=20 compress-algo and unicode-mode. The rest should have reasonable = defaults.=20
 
THIS IS MY=20 CODE..
 
  <?php
  $fp =3D = fopen($tmp_name,=20 "rb");
     $buffer =3D fread($fp,=20 filesize($tmp_name));
  fclose($fp);
  $buffer=3D= pg_escape_bytea($buffer);
  $sql=20 =3D "INSERT INTO foo(nombre, descripcion, archivo_bytea, mime, = size) VALUES=20 ('$nombre', '$desc', = pgp_sym_encrypt_bytea('$buffer',123,'cipher-algo=3Daes256'),=20 '$type', $size)";
  ?>
 
ERRORS:  
  ERROR: No=20 function matches the given name and argument types. You might need to = add=20 explicit type casts 
  ERROR: function=20 pgp_sym_encrypt_bytea(unknown, integer, unknown) does not exist=20
  
OTHER CODE WITH EXPLICIT=20 TYPES
  
  <?php
  $fp =3D=20 fopen($tmp_name, "rb");
     $buffer =3D = fread($fp,=20 filesize($tmp_name));
  fclose($fp);
  $buffer=3D= pg_escape_bytea($buffer);
  $sql=20 =3D "INSERT INTO foo(nombre, descripcion, archivo_bytea, mime, = size) VALUES=20 ('$nombre', '$desc',=20 pgp_sym_encrypt_bytea('$buffer'::bytea,123::text,'cipher-algo=3Daes256'::= text),=20 '$type', $size)";
  ?>
 
ERRORS:
  ERROR: function=20 pgp_sym_encrypt_bytea(bytea, text, text) does not=20 exist 
  
any help is=20 welcome!
  
  
------=_NextPart_000_0013_01C93385.CB3B7C30--