pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Struck <struck.d@retrovirology.lu>
To: pgsql-php@postgresql.org
Subject: Re: pgcrypto & php
Date: Mon, 12 Jan 2004 15:35:51 +0100
Message-ID: <20040112153551.0335d931.struck.d@retrovirology.lu> (raw)
In-Reply-To: <20040112113421.02427893.struck.d@retrovirology.lu>
References: <20040112113421.02427893.struck.d@retrovirology.lu>

Finally, it works :-)

$crypt=$test->result();
echo "<br />";
echo "crypted content from postgresql: " .$crypt;
echo "<br />";
$crypt=pg_unescape_bytea($crypt);
echo $crypt;
echo "<br />";
echo mcrypt_decrypt ( MCRYPT_RIJNDAEL_128 , "fooz", $crypt, cbc);
echo "<br />";
echo  mcrypt_cbc (MCRYPT_RIJNDAEL_128, "fooz", $crypt , MCRYPT_DECRYPT);

OUTPUT:

crypted content from postgresql: g°ñ\220399ùû¹qyg®Û~
g°ñ399ùû¹qyg®Û~
daniel
daniel 


You have to use the function "pg_unescape_bytea();" from PHP when you extract bytea data from postgresql. How stupid of me, should have known that the bytea data would be escaped ;-)

Daniel



view thread (2+ messages)

Message-ID: <20040112153551.0335d931.struck.d@retrovirology.lu>
Permalink:  ../20040112153551.0335d931.struck.d@retrovirology.lu/
Also on:    postgresql.org/message-id/20040112153551.0335d931.struck.d@retrovirology.lu

 · 

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: struck.d@retrovirology.lu
  Subject: Re: pgcrypto & php
  In-Reply-To: <20040112153551.0335d931.struck.d@retrovirology.lu>
  References: <20040112113421.02427893.struck.d@retrovirology.lu> <20040112153551.0335d931.struck.d@retrovirology.lu>

* 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