Someone asked me about a CRC32B checksum today. No problem, there is CPAN and a common checksum like CRC should be very easy, there must be a module (or two or three or so) on CPAN, task done, next one. Stop. There are two modules for CRC32: Digest::CRC32 and String::CRC32 but really nothing for CRC32B.
Google didn’t find anything useful at all until I stumbled on PHP.net, home of the famous HTML preprocessor some people still call a “programming language”. It looks like CRC32B doesn’t exist at all and has been invented by PHP, official versions seems to be CRC32C and CRC32K.
I found a web-based CRC32B calculator and tried to hash the same string with Perl:
PHP/Web: 1b851995
perl -MString::CRC32 -le 'print unpack("h*",pack("L",crc32("Hello world!")));' 599158b1
Nice, isn’t it? The great CRC32B is nothing more than a reversed standard CRC32, add a reverse and you get the same result as PHP:
perl -MString::CRC32 -le 'print scalar(reverse(unpack("h*",pack("L",crc32("Hello world!")))));' 1b851995
That’s all folks.


1 Kommentar. Schreib was dazu
Great! Thanks a lot