PHP的MD5加密解密函数
function encode($code,$seed = "qh8.net", $safe = false){
if ($safe) $code = base64_encode(strrev(str_rot13($code)));
$c_l = strlen($code);
$s_m = md5($seed);
$s_l = strlen($m);
$a=0;
while ($a <$c_l){
$str .= sprintf ("%'02s",@base_convert(ord($code{$a})+ord($s_m{$s_l
% $a+1}),10,32));
$a++;
}
return $str;//wordwrap($str, 80, "n", true)
}
function
decode($code, $seed = 'qh8.net', $safe = false){
//$code = preg_replace("'[ rnt]+'", '', $code);
preg_match_all("/.{2}/", $code, $arr);
$arr = $arr[0];
$s_m = md5($seed);
$s_l = strlen($m);
$a = 0;
foreach ($arr as $value){
$str .= @chr(@base_convert($value,32,10)-ord($s_m{$s_l %
$a+1}));
$a++;
}
if ($safe) $str = str_rot13(strrev(base64_decode($str)));
return $str;
}
网络上志同道合,我们一起学习网络安全,一起进步,QQ群:694839022