|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32432 crc32() sometimes gives different values than other CRC32 engines
Submitted: 2005-03-23 18:59 UTC Modified: 2005-03-23 19:10 UTC
From: alex at primafila dot net Assigned:
Status: Not a bug Package: *Encryption and hash functions
PHP Version: 4.3.10 OS: Linux, Darwin
Private report: No CVE-ID: None
 [2005-03-23 18:59 UTC] alex at primafila dot net
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');"
perl -MString::CRC32 -e 'print crc32("htmlhptaccuin")'

#This doesn't:
php -r "echo crc32('html:hp_taccuino');"
perl -MString::CRC32 -e 'print crc32("html:hp_taccuino")'

Expected result:
I expect to have the same CRC32 hash everywhere, so I 
expect to get 2729568785 in the above example.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-23 19:03 UTC]
PHP only has signed integers, use:
php -r "printf('%u', crc32('html:hp_taccuino'));"

and you see it works fine.
 [2005-03-23 19:10 UTC] alex at primafila dot net
Thank you a lot. Not only you were so fast, but you're 
also right :-)
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Feb 27 04:01:26 2020 UTC