I have problem when decrypt in PHP on the web server, it s fail when I try to decyrpt my
encryption that store in the database, the output of the decrypt show in symbol like this:
±8¼®¿2>~ë¥Ùn�
here is the code that I used for decrypt:
encrypt/decrypt
<?php
class MCrypt
{
private $iv = fedcba9876543210 ;
private $key = 0123456789abcdef ;
function_construct()
{
}
function decrypt($code)
{
//$key = $this->hex2bin($key);
$code = $this->hex2bin($code);
$iv = $this->iv;
$td = mcrypt_module_open( rijndael-128 , , cbc , $iv);
mcrypt_generic_init($td, $this->key, $iv);
$decrypted = mdecrypt_generic($td, $code);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return utf8_encode(trim($decrypted));
}
protected function hex2bin($hexdata)
{
$bindata = ;
for ($i = 0; $i < strlen($hexdata); $i += 2)
{
$bindata .= chr(hexdec(substr($hexdata, $i, 2)));
}
return $bindata;
}
}
?>
and here is the code I used to get the encrypt data from database:
include ("decrypt.php");
$sql = "SELECT * FROM Save_data";
$mcrypt = new MCrypt();
#Decrypt
$decrypted1 = $mcrypt->decrypt($exif_datetime);
echo $decrypted1;