0){ if($i++ > 0) $js .= "+"; $temp = rand(1, $val); $val -= $temp; $js .= $temp; } $js .= ";"; break; } $js .= "} $function_name ();"; // pack bytes function strToLongs($s) { $l = array(); // pad $s to some multiple of 4 $s = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY); while(count($s) % 4 != 0){ $s [] = ' '; } for ($i = 0; $i < ceil(count($s)/4); $i++) { $l[$i] = ord($s[$i*4]) + (ord($s[$i*4+1]) << 8) + (ord($s[$i*4+2]) << 16) + (ord($s[$i*4+3]) << 24); } return $l; } // xor all the bytes with a random key $key = rand(21474836, 2126008810); $js = strToLongs($js); for($i = 0; $i < count($js); $i++){ $js[$i] = $js[$i] ^ $key; } // libs function encapsulation $libs_name = hashcash_random_string(rand(6,18), $expired); $expired [] = $libs_name; $libs = "function $libs_name(){"; // write bytes to javascript, xor with key $data_name = hashcash_random_string(rand(6,18), $expired); $expired [] = $data_name; $libs .= "var $data_name = new Array(" . count($js) . "); "; for($i = 0; $i < count($js); $i++){ $libs .= $data_name . '[' . $i . '] = ' . $js[$i] . ' ^ ' . $key .'; '; } // convert bytes back to string $libs .= " var a = new Array($data_name.length); "; $libs .= "for (var i=0; i<" . $data_name . ".length; i++) { "; $libs .= 'a[i] = String.fromCharCode(' . $data_name .'[i] & 0xFF, ' . $data_name . '[i]>>>8 & 0xFF, '; $libs .= $data_name . '[i]>>>16 & 0xFF, ' . $data_name . '[i]>>>24 & 0xFF); } '; $libs .= "return eval(a.join('')); "; // call libs function $libs .= "} $libs_name();"; // return code echo $libs; ?>