Home >Backend Development >PHP Tutorial > JS 代码转 PHP 多谢
JS 代码转 PHP 谢谢
这是是JS的, 我想转成PHP的,
不懂PHP,谢谢呀
function Getkey(key, sc) {
return (key * 0x0063 + sc) % 0x100
}
function Apple(str) {
var len = str.length / 2;
var i = 1;
var tmp = '';
var key = eval("0x" + str.charAt(0) + str.charAt(1));
while (i istr = eval("0x" + str.charAt(i * 2) + str.charAt(i * 2 + 1));
istr = key ^ istr;
if (istr == 2) {
i = i + 1;
key = Getkey(key, istr);
istr = eval("0x" + str.charAt(i * 2) + str.charAt(i * 2 + 1));
istr = key ^ istr;
jstr = istr;
i = i + 1;
key = Getkey(key, istr);
istr = eval("0x" + str.charAt(i * 2) + str.charAt(i * 2 + 1));
istr = key ^ istr;
jstr = jstr * 256 + istr;
tmp = tmp + String.fromCharCode(jstr)
} else tmp = tmp + String.fromCharCode(istr);
i = i + 1;
key = Getkey(key, istr)
}
return tmp
}
------解决方案--------------------
echo Apple("123123");//输出 "#:" 对吗? function Getkey($key, $sc){ return ($key * 0x0063 + $sc) % 0x100; } function Apple($str) { $len = mb_strlen($str, "GBK") / 2; $i = 1; $tmp = ''; $key = "0x" . $str{0} . $str{1} + 0; while ($i <font color="#e78608">------解决方案--------------------</font><br>楼上厉害! <br><font color="#e78608">------解决方案--------------------</font><br>