note 22225 added to function.crc32
| From: | martin at list-petersen dot dk | Date: | Tue, 11 Jun 2002 10:30:46 +0000 |
| Subject: | note 22225 added to function.crc32 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31695@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;
}
--
http://www.php.net/manual/en/function.crc32.php
http://master.php.net/manage/user-notes.php?action=edit+22225
http://master.php.net/manage/user-notes.php?action=delete+22225
http://master.php.net/manage/user-notes.php?action=reject+22225