我也不知道是什么问题啦~~烦四了~~(关于Mcrypt)

hodat 2003-08-21 10:59:05
我的代码:
-----------------------------
<?
$EnCoder_Key="WelCome 2 The 9 Station !@#$%";
$EnCoder_type=MCRYPT_RIJNDAEL_128; //加密类型


$string[]="我爱逆水行舟大声疾呼";
$string[]="认证介绍 精选Dump 精选文章";
$string[]="网站加速 PHP 缓冲的免费实现方法";
$string[]="用PHP写的SMTP类,支持附件(多个),";
$string[]="在编辑器中带颜色,如果您还没有";


for($i=0;$i<count($string);$i++){
$tt[]=Do_Crypt($string[$i]);
}
echo "<pre>";
print_r($tt);
echo "</pre>";

for($k=0;$k<count($tt);$k++){
$kk[]=Do_Uncrypt($tt[$k]);
}

echo "<pre>";
print_r($kk);
echo "</pre>";


function Do_Crypt($s){
global $EnCoder_Key,$EnCoder_type;

$iv = mcrypt_create_iv(mcrypt_get_iv_size($EnCoder_type,MCRYPT_MODE_ECB), MCRYPT_RAND);
$encrypted_stringa = mcrypt_encrypt( $EnCoder_type, $EnCoder_Key, trim($s), MCRYPT_MODE_CBC, $iv);
$encrypted_string = bin2hex($encrypted_stringa);
return $encrypted_string;
}

function Do_Uncrypt($s){
global $EnCoder_Key,$EnCoder_type;

$saa=trim($s);
unset($string_en);
$string_en=hex2bin($saa);
$iv = mcrypt_create_iv(mcrypt_get_iv_size($EnCoder_type,MCRYPT_MODE_ECB), MCRYPT_RAND);
$decrypted_string = mcrypt_decrypt( $EnCoder_type, $EnCoder_Key, trim($string_en), MCRYPT_MODE_CBC, $iv);
return trim($decrypted_string);
}

function hex2bin($hexdata) {

for ($i=0;$i<strlen($hexdata);$i+=2) {
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
}

return $bindata;
}
?>

得到的结果~~

Array
(
[0] => 53b919490432e7037e544ad5af0e1f68b42a5a73dd00ba68b878f6601ccca8b8
[1] => 5b9f4e6040cc46ecd9f012a326d711baf9886e9051ad10021c320ec87c32920b
[2] => ec359b112ed26fd78458e6644a329e0ab262c2f011ea935e7b872f355db4e01b
[3] => 23971d0d5896bc7976c2e48b02664984e8fa12f9fc1549342f352f06e212787b
[4] => b353aa1c6abcde8931b145ec56d79e0ec08cd733c6305b279b56417229bcb8ac
)

Array
(
[0] => j磈ゃI?
哚y$a疾呼
[1] => 韭馑=鋘莿(?櫍`?`艵阒?? [2] => ?1毩g检簖G梾w宓拿夥咽迪址椒? [3] => 嵏o?氦)徱堣支持附件(多个),
[4] => 悯緭)o梈?斞遡f?如果您还没有
)


为什么这样啊??

望高手指点!~~~
...全文
43 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuiaaa 2003-08-22
  • 打赏
  • 举报
回复
default_mimetype = "text/html"
default_charset = "GB2312"
hodat 2003-08-21
  • 打赏
  • 举报
回复
页面加了

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

php.ini

default_mimetype = "text/html"
default_charset = "GB2312"
licalig 2003-08-21
  • 打赏
  • 举报
回复
在网页中有没有加入以下内容:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

你用的服务器是IIS还是Aapche?

php.ini中的
default_charset = "GB2312"有没有设?

……

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧