<?
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
?>