note 22225 deleted from function.crc32 by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Sun, 29 Dec 2002 22:40:54 +0000 |
| Subject: | note 22225 deleted from function.crc32 by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-41433@lists.php.net to get a copy of this message | ||
If you need a crc16 instead, this should work:
define('CRC_POLYNOMIAL', '0x8005');
function crc16($string)
{
$crc = 0;
for($x=0; $x < strlen($string); $x++)
{
$crc = $crc ^ (ord($string[$x]) << 8);
for($y=1; $y < 9; $y++)
{
if (($crc & 0x8000) != 0)
{
$crc = (($crc << 1) ^ CRC_POLYNOMIAL);
} else {
$crc = $crc << 1;
}
}
}
$crc = $crc & 0xFFFF;
return $crcstr;
}