note 72480 deleted from function.crc32 by nlopess

From: Date: Wed, 24 Jan 2007 19:47:13 +0000
Subject: note 72480 deleted from function.crc32 by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122156@lists.php.net to get a copy of this message
Note Submitter: joe dot OMIT dot nemeth at palg dot com ---- 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); ?>

« previous php.notes (#122156) next »