note 86628 deleted from function.crc32 by danbrown
| From: | danbrown@php.net | Date: | Thu, 06 Oct 2011 21:25:26 +0000 |
| Subject: | note 86628 deleted from function.crc32 by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183680@lists.php.net to get a copy of this message | ||
Note Submitter: lenar at city dot ee
----
Simplest/fastest crc16 (CRC-CCITT-16 0x1021) implementation I could find:
(and credit goes to http://www.ccsinfo.com/forum/viewtopic.php?t=24977)
<?php
function crc16($data)
{
$crc = 0xFFFF;
for ($i = 0; $i < strlen($data); $i++)
{
$x = (($crc >> 8) ^ ord($data[$i])) & 0xFF;
$x ^= $x >> 4;
$crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF;
}
return $crc;
}