guyra has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I need to implemenmt CRC-32 (with custom poly) in Perl.
I have seen that there is a module called digest::crc that does it.
However, when I compare the result to an online calculator, I dont get the same CRC code.
My poly is "101101" (bin) or "2d" (hex)
My data is "1e5"
The online calc is:
https://ghsi.de/CRC/index.php?Polynom=101101&Message=1e5
The result that I get from the calc is "1010" (bin) or "A" (hex)
This is the perl code I used (found somewhere online...):
use strict; use warnings; use Digest::CRC; my $string = 0x01e5; my $ctx = Digest::CRC->new(type=>"crc32", poly=>0x2D); $ctx->add($string); print "CRC for '$string' is 0x" . $ctx->hexdigest . "\n";
This is the output of this perl:
CRC for '485' is 0x9d0fec86
I'm pretty sure that the online calculator is correct.
Can someone help me understand what is wrong with my Perl code?
Thx!
Guy
|
|---|