I am quite new to VB.NET and I am trying to implement something in Visual Studio 2013 to calculate the CRC-32 bytes of an array of bytes. I have come across a variety of examples, some in VB.NET and some in C#. Nonetheless, I have not been successful in getting them to work or even test them.
For example consider this particular code from "Mangus" which I found on this website. I copied and pasteed it into a windows form template and I get this error:
error BC30456: 'Dump' is not a member of 'UInteger'.
I apologize as I might be doing something really silly, but I appreciate any help or hints.
Private Sub Main()
Crc32.ComputeChecksum(Encoding.UTF8.GetBytes("Some string")).Dump()
End Sub
Public Class Crc32
Shared table As UInteger()
Shared Sub New()
Dim poly As UInteger = &Hedb88320UI
table = New UInteger(255) {}
Dim temp As UInteger = 0
For i As UInteger = 0 To table.Length - 1
temp = i
For j As Integer = 8 To 1 Step -1
If (temp And 1) = 1 Then
temp = CUInt((temp >> 1) Xor poly)
Else
temp >>= 1
End If
Next
table(i) = temp
Next
End Sub
Public Shared Function ComputeChecksum(bytes As Byte()) As UInteger
Dim crc As UInteger = &HffffffffUI
For i As Integer = 0 To bytes.Length - 1
Dim index As Byte = CByte(((crc) And &Hff) Xor bytes(i))
crc = CUInt((crc >> 8) Xor table(index))
Next
Return Not crc
End Function
End Class