Tcl Library Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: 2512528
Title: crc32 wrong with -seed option
Type: Bug Version: None
Submitter: wowbagger Created on: 2009-01-16 06:07:57
Subsystem: crc Assigned To: patthoyts
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-03-04 07:55:23
Resolution: Invalid Closed By: patthoyts
    Closed on: 2009-03-04 00:55:23
Generating crc32 of the strings '?' and 'Hello' generates the correct values as tested agains other code and online crc generators.

Using the command crc::crc32 -seed [crc::crc32 ?] Hello produces the crc 0x4cc062a6 other tools generate the crc of 0xC2A6E6F2. Trf and critcl not used.
User Comments: patthoyts added on 2009-03-04 07:55:23:
allow_comments - 1

The crc32 algorithm includes a finalization step where the result of the algorithm is xor'd. To use it for chaining segments as you are trying to do you would need to undo the xor to feed the result from one step into the seed for the next.
eg: crc32 -seed [expr {[crc32 $data] ^ 0xffffffff}] $moredata

This is presented already in a more usable form using the Crc32Init/Crc32Update/Crc32Final methods which have been written for this kind of incremental checksum.