В общем как и предпологалось, ничего не работает
function rc4($e, $g) {
$f = array();
$b = 0;
$a= $d = "";
for ($c = 0; $c < 256; $c++) {
$f[$c] = $c;
}
for ($c = 0; $c < 256; $c++) {
$b = ($b + $f[$c] + charCodeAt($e, $c % mb_strlen($c))) % 256;
$a = $f[$c];
$f[$c] = $f[$b];
$f[$b] = $a;
}
$c = 0;
$b = 0;
for ($h = 0; $h < mb_strlen($g); $h++) {
$c = ($c + 1) % 256;
$b = ($b + $f[$c]) % 256;
$a = $f[$c];
$f[$c] = $f[$b];
$f[$b] = $a;
$d .= utf8_chr(charCodeAt($g,$h) ^ $f[($f[$c] + $f[$b]) % 256]);
}
return $d;
}
//var Base64 = {
function Base64encode($c) {
$_keyStr= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
$a = "";
//var k, h, f, j, g, e, d;
$b = 0;
$c = Base64_utf8_encode($c);
while ($b < mb_strlen($c)) {
$k = charCodeAt($c,$b++);
$h = charCodeAt($c,$b++);
$f = charCodeAt($c,$b++);
$j = $k >> 2;
$g = (($k & 3) << 4) | ($h >> 4);
$e = (($h & 15) << 2) | ($f >> 6);
$d = $f & 63;
if (is_nan($h)) {
$e = $d = 64;
} else {
if (is_nan($f)) {
$d = 64;
}
}
$a = $a . charAt($_keyStr,$j) . charAt($_keyStr,$g) . charAt($_keyStr,$e) . charAt($_keyStr,$d);
}
return $a;
}
function Base64decode($c) {
$_keyStr= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
$a = "";
//var k, h, f;
//var j, g, e, d;
$b = 0;
$c = preg_replace('/[^A-Za-z0-9\+\/\=]/', '', $c);//$c = c.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while ($b < mb_strlen($c)) {
$j = mb_strpos($_keyStr,charAt($c,$b++));
$g = mb_strpos($_keyStr,charAt($c,$b++));
$e = mb_strpos($_keyStr,charAt($c,$b++));
$d = mb_strpos($_keyStr,charAt($c,$b++));
$k = ($j << 2) | ($g >> 4);
$h = (($g & 15) << 4) | ($e >> 2);
$f = (($e & 3) << 6) | $d;
$a = $a . utf8_chr($k);
if ($e != 64) {
$a = $a . utf8_chr($h);
}
if ($d != 64) {
$a = $a . utf8_chr($f);
}
}
$a = Base64_utf8_decode($a);
return $a;
}
function Base64_utf8_encode($b) {
$_keyStr= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
$b = preg_replace('/\r\n/', "\n", $b); //$b = b.replace(/\r\n/g, "\n");
$a = "";
for ($e = 0; $e < mb_strlen($b); $e++) {
$d = charCodeAt($b,$e);
if ($d < 128) {
$a .= utf8_chr($d);
} else {
if (($d > 127) && ($d < 2048)) {
$a .= utf8_chr(($d >> 6) | 192);
$a .= utf8_chr(($d & 63) | 128);
} else {
$a .= utf8_chr(($d >> 12) | 224);
$a .= utf8_chr((($d >> 6) & 63) | 128);
$a .= utf8_chr(($d & 63) | 128);
}
}
}
return $a;
}
function Base64_utf8_decode($a) {
$_keyStr= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
$b = "";
$d = 0;
$e = $c1 = $c2 = 0;
while ($d < mb_strlen($a)) {
$e = charCodeAt($a,$d);
if ($e < 128) {
$b .= utf8_chr($e);
$d++;
} else {
if (($e > 191) && ($e < 224)) {
$c2 = charCodeAt($a,$d + 1);
$b .= utf8_chr((($e & 31) << 6) | ($c2 & 63));
$d .= 2;
} else {
$c2 = charCodeAt($a,$d + 1);
$c3 = charCodeAt($a,$d + 2);
$b .= utf8_chr((($e & 15) << 12) | (($c2 & 63) << 6) | ($c3 & 63));
$d .= 3;
}
}
}
return $b;
}
function charAt($str, $pos)
{
return $str{$pos};
}
function unichr($u) {
return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
}
function utf8_chr($num) {
if($num<128) return chr($num);
if($num<2048) return chr(($num>>6)+192).chr(($num&63)+128);
if($num<65536) return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
if($num<2097152) return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128).chr(($num&63)+128);
return false;
}
function charCodeAt($str, $num) { return utf8_ord(utf8_charAt($str, $num)); }
function utf8_ord($ch) {
$len = strlen($ch);
if($len <= 0) return false;
$h = ord($ch{0});
if ($h <= 0x7F) return $h;
if ($h < 0xC2) return false;
if ($h <= 0xDF && $len>1) return ($h & 0x1F) << 6 | (ord($ch{1}) & 0x3F);
if ($h <= 0xEF && $len>2) return ($h & 0x0F) << 12 | (ord($ch{1}) & 0x3F) << 6 | (ord($ch{2}) & 0x3F);
if ($h <= 0xF4 && $len>3) return ($h & 0x0F) << 18 | (ord($ch{1}) & 0x3F) << 12 | (ord($ch{2}) & 0x3F) << 6 | (ord($ch{3}) & 0x3F);
return false;
}
function utf8_charAt($str, $num) { return mb_substr($str, $num, 1, 'UTF-8'); }