note 104202 added to function.crc32

From: Date: Tue, 31 May 2011 18:39:18 +0000
Subject: note 104202 added to function.crc32
Groups: php.notes 
Request: Send a blank email to php-notes+get-180141@lists.php.net to get a copy of this message
I would like to expand a little bit of information about the code "lenar at city dot ee 27-Oct-2008 08:25" mentioned. About: Optimized CRC16-CCITT (0xFFFF) Code. It doesn't returns a hex expressed CRC16-CCITT, instead, returns a decimal integrer. The result to be used, as part of a string to be sended to any device/application that would interpretate it as HEX code (e.g. part of a device protocol), first you'll need to base convert it to hex, and code it as binary hex data. function INTtorawHEX ( $integrer ) { $hex = base_convert($integrer, 10, 16); $rawhex = pack("H*", $hex); return $rawhex;} 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; } $crc = INTtorawHEX($crc); return $crc; } ---- Server IP: 69.147.83.197 Probable Submitter: 189.248.168.217 ---- Manual Page -- http://www.php.net/manual/en/function.crc32.php Edit -- https://master.php.net/note/edit/104202 Del: integrated -- https://master.php.net/note/delete/104202/integrated Del: useless -- https://master.php.net/note/delete/104202/useless Del: bad code -- https://master.php.net/note/delete/104202/bad+code Del: spam -- https://master.php.net/note/delete/104202/spam Del: non-english -- https://master.php.net/note/delete/104202/non-english Del: in docs -- https://master.php.net/note/delete/104202/in+docs Del: other reasons-- https://master.php.net/note/delete/104202 Reject -- https://master.php.net/note/reject/104202 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180141) next »