Answer the question
In order to leave comments, you need to log in
Function ord,chr from php, how to implement?
Tell me please.
There is a package unpacking code written in php.
And the line:
$part[$i] = chr(ord($part[$i]) ^ ord($zBytes[$i]));
'Ф'.charCodeAt(0)
function UnMunge($packet) {
$MungeTable2 = array(0x05, 0x61, 0x7A, 0xED, 0x1B, 0xCA, 0x0D, 0x9B, 0x4A, 0xF1, 0x64, 0xC7, 0xB5, 0x8E, 0xDF, 0xA0);
$z = ord($packet[0]);
$packet = substr($packet, 8);
$length = strlen($packet);
$res = "";
$count = 0;
if ($length < 1) {
return null;
}
$notz = ~$z;
$length = $length >> 2;
$zBytes = pack("L", $z);
$notzBytes = pack("L", $notz);
$x = 0;
while ($length--) {
$part = substr($packet, $count * 4, 4);
for ($i = 0; $i < 4; $i++) {
$part[$i] = chr(ord($part[$i]) ^ ord($zBytes[$i]));
}
for ($i = 0; $i < 4; $i++) {
$part[$i] = chr(ord($part[$i]) ^ ((($MungeTable2[($count + $i) & 0x0F] | ($i << $i)) | $i) | 0xA5));
}
$s = "0000";
for ($i = 0, $i2 = 3; $i < 4; $i++, $i2--) {
$s[$i] = chr(ord($part[$i2]) ^ ord($notzBytes[$i]));
}
$res .= $s;
$count++;
}
return $res;
}
$a = '010000c0010000805a18010051001041032a40016001014124660f377e3933737948106f908fd021c1b8c0812ba8c0f3a5c8f4919b99d1d0f48083908120e091d1d881be8becc0b48a99d1bfcbb0c0c3d1ab90b3c2fdc0f4411a71ca';
$a = hex2bin($a);
var_dump(UnMunge($a));
string(84) "J:Asv_version* Права доступа предоставлены! "
Answer the question
In order to leave comments, you need to log in
You may have heard there is such a thing as text encodings , and the increasing use is UTF-8 , which is a multi-byte encoding.
And ord() is a function for working with single-byte.
function showOrd($char) {
echo "\"$char\""
. ' ord='.ord($char)
. ' mb_ord='.mb_ord($char)
. PHP_EOL;
}
showOrd('а'); // "а" ord=208 mb_ord=1072
showOrd('ф'); // "ф" ord=209 mb_ord=1092
showOrd('я'); // "я" ord=209 mb_ord=1103
$str = "Ф";
for ( $pos=0; $pos < strlen($str); $pos ++ ) {
$byte = substr($str, $pos);
echo 'Byte ' . $pos . ' of $str has value ' . ord($byte) . PHP_EOL;
}
// Byte 0 of $str has value 208
// Byte 1 of $str has value 164
you just need to parse the starting game packages.Do you have them as a string or is it a binary? If a binary, then work with it as with a binary.
fReader.readAsArrayBuffer(file);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question