Re: pgcrypto & php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux