• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 694
  • Last Modified:

How to combine two CRC32 results

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

Open in new window

0
vigylant
Asked:
vigylant
1 Solution
 
grayeCommented:
The short answer is No...   the CRC algorythm needs to "see" all of the bytes
0
 
vigylantAuthor Commented:
Was afraid of that :(
Well, thanks anyway.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now