Re: pgcrypto & php - Mailing list pgsql-php

From Daniel Struck
Subject Re: pgcrypto & php
Date
Msg-id 20040112153551.0335d931.struck.d@retrovirology.lu
Whole thread Raw
In response to pgcrypto & php  (Daniel Struck <struck.d@retrovirology.lu>)
List pgsql-php
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

pgsql-php by date:

Previous
From: Daniel Struck
Date:
Subject: pgcrypto & php
Next
From: Douglas Douglas
Date:
Subject: pg_connect socket creation error (0x0000273F)