Imagine that we have CRC32 values(Cycle Redundancy Check) of two different messages. How to calculate their common CRC32? For example:
- CRC32 of "hello" = 3610a686
- CRC32 of "world" = 3a771143
- CRC32 of "helloworld" = f9eb20ad
Imagine that we have CRC32 values(Cycle Redundancy Check) of two different messages. How to calculate their common CRC32? For example:
Combining the separately calculated CRCs of two (or more) blocks in order to get the CRC for the concatenation of these blocks is possible, but it is not trivial and involves quite a bit of linear algebra.
zlib contains a function crc32_combine()
that does the work for you, and many reasonably good (and reasonably current) libraries offer similar functionality. Mark Adler (yes, the Mark Adler of the homonymous checksum) has posted a good explanation in the topic CRC Calculation Of A Mostly Static Data Stream.
The Intel document Fast CRC Computation for iSCSI Polynomial Using CRC32 Instruction explains the process in gory detail.
CRC32 uses an initial value of 0xFFFFFFFF, and post complements the CRC by xoring it with 0xFFFFFFFF (or using not). If you had a modified CRC32 that took these values as parameters, then the first call for "hello" would use initial value = 0xFFFFFFFF, xorout = 0x00000000, such as CRC = CRC32X(0xFFFFFFFF, 0x00000000, "hello", 5), where the 3rd parameter is a pointer to a string, and the 4th parameter the number of bytes in the string. The second call would be CRC32X(CRC, 0xFFFFFFFF, "world", 5), where CRC is the value returned by the first call.