I've tried to convert these functions from AS2 to PHP, but I've had no luck.
Here is the original AS2 function:
enc.charsToLongs = function (chars)
{
var _loc3 = chars;
var tlength = Math.ceil(_loc3.length / 4);
var temp = [];
var _loc2 = 0;
for (var _loc1 = 0; _loc1 < tlength; ++_loc1)
{
_loc2 = _loc1 * 4;
temp[_loc1] = (_loc3[_loc2] << 24) + (_loc3[_loc2 + 1] << 16) + (_loc3[_loc2 + 2] << 8) + _loc3[_loc2 + 3];
}
return (temp);
};
This is what I have in PHP:
function charsToLongs($chars)
{
$_loc3 = $chars;
$tlength = ceil(count($_loc3) / 4);
$temp = array();
$_loc2 = 0;
for ($_loc1 = 0; $_loc1 < $tlength; $_loc1++) {
$_loc2 = $_loc1 * 4;
$temp[$_loc1] = ($_loc3[$_loc2] << 24) + ($_loc3[$_loc2 + 1] << 16) + ($_loc3[$_loc2 + 2] << 8) + $_loc3[$_loc2 + 3];
}
return ($temp);
}
Whenever I run the functions I get different answers for both. I know the AS2 one is working perfectly fine because I've used it many times to encrypt/decrypt strings perfectly fine. There are more functions too but this seems to be the only one I'm stuck on. Could someone tell me what's wrong?
Also: chars ($chars/chars) is an array of character ASCII values of the string I want to encrypt.
Thanks.