We help IT Professionals succeed at work.

# How to combine two CRC32 results

on
Medium Priority
900 Views
The thing is, i want to combine two calculated CRC32's...

Example:

The CRC32 of GetCRC32(New Byte() {1}) is 1526341860
The CRC32 of GetCRC32(New Byte() {2}) is -1007455906

Now, say i do not have access to the bytes (1 and 2) anymore, but i do have access to the CRC32 results (1526341860 and -1007455906).
Is it possible to combine these results as if the original calculation were GetCRC32(New Byte() {1, 2})?
``````Public Class Checksum

Private CRC32Table(255) As Integer

Public Sub New()

Dim dwPolynomial As Integer = -306674912
Dim j, dwCrc As Integer

For i As Integer = 0 To 255
dwCrc = i
For j = 8 To 1 Step -1
If (dwCrc And 1) Then
dwCrc = ((dwCrc And -2) \ 2&) And 2147483647
dwCrc = dwCrc Xor dwPolynomial
Else
dwCrc = ((dwCrc And -2) \ 2&) And 2147483647
End If
Next j
CRC32Table(i) = dwCrc
Next

End Sub

Public Function GetCRC32(ByRef bt() As Byte) As Integer

Dim CRC32Result As Integer = -1
Dim iLookup As Integer

For Each b As Byte In bt

iLookup = (CRC32Result And 255) Xor b
CRC32Result = ((CRC32Result And -256) \ 256) And 16777215
CRC32Result = CRC32Result Xor CRC32Table(iLookup)

Next

Return CRC32Result

End Function

End Class
``````
Comment
Watch Question

## View Solution Only

Commented:
The short answer is No...   the CRC algorythm needs to "see" all of the bytes

Not the solution you were looking for? Getting a personalized solution is easy.

Commented:
Was afraid of that :(
Well, thanks anyway.
##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile