1,开启mcrypt扩展
参考:
2、php AES对称解密代码
/*
* 实现AES解密
* $str: 要解密的字符串
* $keys : 加密密钥
* $iv : 加密向量
* $cipher_alg :加密方式
*/
function decryptStrin($str,$keys,$iv="8105547186756232",$cipher_alg=MCRYPT_RIJNDAEL_128){
$decrypted_string = mcrypt_decrypt($cipher_alg, $keys, pack("H*",$str),MCRYPT_MODE_CBC, $iv);
return $decrypted_string;
}
define("KEY","wo shi key");
$content = '我是内容ase';
$encrypt = ecryptdString($content,KEY);
echo $encrypt;
echo '<BR>';
echo decryptStrin($encrypt,KEY);
6321893597b379726748a1eeac7091ee
我是内容ase