#32432 [Bgs]: crc32() sometimes gives different values than other CRC32 engines
| From: | alex at primafila dot net | Date: | Wed, 23 Mar 2005 18:10:26 +0000 |
| Subject: | #32432 [Bgs]: crc32() sometimes gives different values than other CRC32 engines | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-75765@lists.php.net to get a copy of this message | ||
ID: 32432
User updated by: alex at primafila dot net
Reported By: alex at primafila dot net
Status: Bogus
Bug Type: *Encryption and hash functions
Operating System: Linux, Darwin
PHP Version: 4.3.10
New Comment:
Thank you a lot. Not only you were so fast, but you're
also right :-)
Previous Comments:
------------------------------------------------------------------------
[2005-03-23 19:03:26] derick@php.net
PHP only has signed integers, use:
php -r "printf('%u', crc32('html:hp_taccuino'));"
and you see it works fine.
------------------------------------------------------------------------
[2005-03-23 18:59:29] alex at primafila dot net
Description:
------------
While comparing crc32()'s output with other languages'
CRC32 functions I note that sometimes the result is
different. Unfortunately all other engines, such as Perl
Digest::Crc32, String::CRC32, Archive::Zip, give always
the same value.
I wasn't able to understand which format leds to this
misbehaving, and I also tried to run crc32() of failing
strings' MD5 hashes: the result is different.
Reproduce code:
---------------
#This works:
php -r "echo crc32('htmlhptaccuin');"
121189226
perl -MString::CRC32 -e 'print crc32("htmlhptaccuin")'
121189226
#This doesn't:
php -r "echo crc32('html:hp_taccuino');"
-1565398511
perl -MString::CRC32 -e 'print crc32("html:hp_taccuino")'
2729568785
Expected result:
----------------
I expect to have the same CRC32 hash everywhere, so I
expect to get 2729568785 in the above example.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32432&edit=1