note 72569 deleted from function.crc32 by nlopess

From: Date: Wed, 24 Jan 2007 19:47:08 +0000
Subject: note 72569 deleted from function.crc32 by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122155@lists.php.net to get a copy of this message
Note Submitter: joe dot OMIT nemeth at palg dot com ---- Mathematical coincidence, and too sparse a test data set. The routines I provided below do NOT work. This one appears to, and is based on examination of the source for the PHP crc32() routine. <?php function packetize($string) { return $string . pack("V", ~crc32($string)); } function verify($packet) { if (~crc32($packet) == 0) return substr($packet, 0, -4); return false; } ?> Similarly, the following appear to be both numerically and formally correct. <?php echo crc32("\x01\x02\x03\x04")."\n"; echo ~mycrc32(0x04030201, 32, 0xEDB88320, 0xffffffff)."\n"; echo ~mycrc32(0x04, 8, 0xEDB88320, mycrc32(0x03, 8, 0xEDB88320, mycrc32(0x02, 8, 0xEDB88320, mycrc32(0x01, 8, 0xEDB88320, 0xffffffff))))."\n"; ?>

« previous php.notes (#122155) next »