时间:2021-07-01 10:21:17 帮助过:5人阅读
header("Content-Type:text/html; charset=utf-8");
$str="床前明月光,疑是地上霜"; //被加密的内容
$key="key:111"; //密匙
$cipher=MCRYPT_DES; //加密算法类型
$mode=MCRYPT_MODE_ECB; //加密算法模式
$iv=mcrypt_create_iv(mcrypt_get_iv_size($cipher, $mode),MCRYPT_RAND); //初始化向量
echo "加密前".$str."
";
//加密
$str_encrypt=mcrypt_encrypt($cipher,$key,$str,$mode,$iv);
echo "加密后".$str_encrypt."
";
//还原
$str_decrypt=mcrypt_encrypt($cipher,$key,$str_encrypt,$mode,$iv);
echo "还原".$str_decrypt."
";
?>