B4J Question [SOLVED] PHP to B4J

jroriz

Active Member
Licensed User
Longtime User
I really need to translate this PHP code to B4J.
Could anybody help me?

PHP:
<?
function crc16($string)
{
$CRC16POLINOMIO = 0x1021;
$result = 0xFFFF;
if (($length = strlen($string)) > 0) {
for ($offset = 0; $offset < $length; $offset++) {
$result ^= (ord($string[$offset]) << 8);
for ($bitwise = 0; $bitwise < 8; $bitwise++) {
if (($result <<= 1) & 0x10000) $result ^= $CRC16POLINOMIO;
$result &= 0xFFFF;
}
}
}
return $result;
}

echo $_GET['pix'] . "<BR>";
$CRC16 = crc16($_GET['pix']);
$CRC16 = dechex($CRC16); //transformo de decimal para hexadecimal
$CRC16 = strtoupper($CRC16); //Transformo para maiusculas

echo $CRC16
?>
 

jroriz

Active Member
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…