English 中文(简体)
PHP的加密解决方案
原标题:Solution for Decrypt in PHP

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; 
问题回答

但是,如果看不懂加密方法,就无法说该守则为何没有像你所期望的那样发挥作用。

return utf8_encode(trim($decrypted));

Eh? 这没有任何意义。 当然,如果你需要改变ISO-8859-1至utf8,那么,这就是你如何去做——但是,这绝不应该采用与加密相同的方法。

当我试图消化我在数据库中储存的加密时。

查阅该守则意味着所收集的数据是作为双向储存的。 真的? 由于各种原因,将64_encode(或改为cii HEX)作为加密数据的基础,然后将其储存在非行(因此,基64-脱编码在加密之前)。

请允许我指出,您的产出是<代码>txt = ±8Â1⁄4®2>~à “Â¥ÃTMnà Loréane,

页: 1

对应数字f8_encode($txt);

或试图添加以下元件:<meta http-equiv=“content-type”内容=“text/html;charset=utf-8”/>

希望会有所助益。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签