note 72480 added to function.crc32

From: Date: Sat, 20 Jan 2007 17:11:29 +0000
Subject: note 72480 added to function.crc32
Groups: php.notes 
Request: Send a blank email to php-notes+get-121953@lists.php.net to get a copy of this message
As I needed to generate crc32 outside PHP, here is some additional information. Using the algorithm below, it appears that the PHP crc32() uses the polynomial constant 0xEDB88320, and starts with a shift value of 0x00000000 (rather than 0xFFFFFFFF). After computation using the algorithm below, the final 32-bit result is XORed with 0x2144DF1C. Note that endianness is important, since what counts is the bit-order of what is fed to the algorithm. The "string" that crc32() processes is treated as an indefinitely long little-endian number, so the first byte is the "first-fed" and therefore least-significant. Thus, the following are equivalent: <?php echo crc32("\x01\x02\x03\x04"); echo mycrc32(0x04030201, 32, 0xEDB88320, 0) ^ 0x2144DF1C; echo mycrc32(0x04, 8, 0xEDB88320, mycrc32(0x03, 8, 0xEDB88320, mycrc32(0x02, 8, 0xEDB88320, mycrc32(0x01, 8, 0xEDB88320, 0)))) ^ 0x2144DF1C); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 24.9.89.42 ---- Manual Page -- http://www.php.net/manual/en/function.crc32.php Edit -- https://master.php.net/note/edit/72480 Del: integrated -- https://master.php.net/note/delete/72480/integrated Del: useless -- https://master.php.net/note/delete/72480/useless Del: bad code -- https://master.php.net/note/delete/72480/bad+code Del: spam -- https://master.php.net/note/delete/72480/spam Del: non-english -- https://master.php.net/note/delete/72480/non-english Del: in docs -- https://master.php.net/note/delete/72480/in+docs Del: other reasons-- https://master.php.net/note/delete/72480 Reject -- https://master.php.net/note/reject/72480 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#121953) next »