pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: elmarkivp <elmarkivo@hotmail.com>
To: pgsql-php@postgresql.org
Subject: store data files encryptypted in database.
Date: Fri, 10 Oct 2008 12:32:28 -0300
Message-ID: <BAY108-DAV74F0B81BD22FF982A3641A3350@phx.gbl> (raw)

hi, i'm trying to store data files encryptypted in postgres 8.1 database but i can`t make it works.
this is what i'm doing.

$link = pg_connect("host=$dbhost user=$dbuser password=$dbpwd dbname=$dbname") or die(pg_last_error($link));
$fp = fopen($tmp_name, "rb");
$file= fread($fp, filesize($tmp_name));
fclose($fp);
$file=pg_escape_bytea($file);
$sql = "INSERT INTO SOME_TABLE (bytea_file)  VALUES (pgp_sym_decrypt_bytea($file,somepass,cipher-algo=aes256))";       
pg_query($link, $sql) or die(pg_last_error($link));

this error appear...

ERROR: column "content_of_bytea_file" does not exist     ( "content_of_bytea_file" is $file)

it seems that whant to the $file be a column ... but thats not what the documentation says...


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
 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. 



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=1, cipher-algo=aes256')
   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. 



thanks

view thread (5+ messages)  latest in thread

Message-ID: <BAY108-DAV74F0B81BD22FF982A3641A3350@phx.gbl>
Permalink:  ../BAY108-DAV74F0B81BD22FF982A3641A3350@phx.gbl/
Also on:    postgresql.org/message-id/BAY108-DAV74F0B81BD22FF982A3641A3350@phx.gbl

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: elmarkivo@hotmail.com
  Subject: Re: store data files encryptypted in database.
  In-Reply-To: <BAY108-DAV74F0B81BD22FF982A3641A3350@phx.gbl>
  References: <BAY108-DAV74F0B81BD22FF982A3641A3350@phx.gbl>

* 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