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;
}
来源:https://www.cnblogs.com/cnsec/archive/2011/03/18/11515929.html