Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^6: How to use perl digest module to calculate CRC?

by guyra (Novice)
on Apr 02, 2013 at 11:17 UTC ( [id://1026659]=note: print w/replies, xml ) Need Help??


in reply to Re^5: How to use perl digest module to calculate CRC?
in thread How to use perl digest module to calculate CRC?

Thanks!

indeed, the SOH does affect the CRC result.

#data = (HEX) 3132 my $ctx = Digest::CRC->new(width => 32, poly => 0x04c11db7, init => +0xFFFFFFFF, xorout => 0xFFFFFFFF, refin => 1, refout => 1); my $r = $ctx->add( pack 'H*', '3132' )->hexdigest; print "data=", (pack 'H*', '3132'), "= | r=$r=\n"; #data = (ASCII) 12 my $ctx = Digest::CRC->new(width => 32, poly => 0x04c11db7, init => +0xFFFFFFFF, xorout => 0xFFFFFFFF, refin => 1, refout => 1); my $r = $ctx->add( "12" )->hexdigest; print "data=", (pack 'H*','3132'), "= | r=$r=\n"; #data = (HEX) 310132 my $ctx = Digest::CRC->new(width => 32, poly => 0x04c11db7, init => +0xFFFFFFFF, xorout => 0xFFFFFFFF, refin => 1, refout => 1); my $r = $ctx->add(pack 'H*','310132' )->hexdigest; print "data=", (pack 'H*', '310132'), "= | r=$r=\n";

Results in:

data=12= | r=4f5344cd= data=12= | r=4f5344cd= data=12= | r=b243674=

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1026659]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-20 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found