CRC32

Given a file name, how do you calculate the corresponding CRC32 value?
LVL 10
caraf_gAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caraf_gAuthor Commented:
(PS - same as pkzip)
0
caraf_gAuthor Commented:
Yes, I saw that, but I don't understand how I pass a file into it; I can't see how it processes binary data.

What I'd like to do is to open a file for binary, dump its contents into a byte array, and then run an algoritm to calculate the CRC32 value.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

mcriderCommented:
Try this:

http://www.vbcode.com/asp/showsn.asp?theID=471 
 
It's waty's code on VBCODE.COM...


Cheers!
0
caraf_gAuthor Commented:
I think everyone is giving me the same routines, but they don't seem to yield the same results.

Here's what's the problem. I've seen the ElfBowl virus hoax:

"Symantec AntiVirus Research Center has received many submissions of these programs developed by NVISION DESIGN,INC including Y2KGAME.EXE and has all been confirmed to be free of viruses. Power users can confirm if the program are clean by comparing the CRC-32 and size of these programs using PKZIP software:

FROGPULT.EXE, CRC32: e0b827fa, SIZE: 1021952 bytes
ELFBOWL.EXE, CRC32: ae35e713, SIZE: 1130496 bytes
Y2KGAME.EXE, CRC32: 80a08aeb, SIZE: 1830612 bytes
"


What I would like to do is run CRC32 on my version of ElfBowl.exe and get ae35e713.

I tried waty's code, as follows:

....

'// And for testing the routines above...
Public Sub GetCRC32ForString(strTest As String)

   Dim lCrc32Value As Long

   On Error Resume Next
   lCrc32Value = InitCrc32()
   lCrc32Value = AddCrc32(strTest, lCrc32Value)
   Debug.Print Hex$(GetCRC32(lCrc32Value))

End Sub



Private Sub Command1_Click()

Dim bytes() As Byte
Dim strTest As String
Dim intFileNumber As Integer

On Error Resume Next
With Me.CommonDialog1
    .DialogTitle = "Open a file"
    .CancelError = True
    .Filter = "All Files *.*|*.*"
    .Flags = cdlOFNExplorer Or cdlOFNFileMustExist Or cdlOFNLongNames
    .ShowOpen
    If Err.Number <> 0 Then
        Exit Sub
    End If
    intFileNumber = FreeFile
    Open .FileName For Binary As intFileNumber
    ReDim bytes(1 To LOF(intFileNumber))
    Get intFileNumber, , bytes
    Close intFileNumber
End With

strTest = bytes

GetCRC32ForString strTest

End Sub

Result:
D202EF8D, not ae35e713
0
caraf_gAuthor Commented:
deighton, I still haven't worked out how to use your code on a file.
0
caraf_gAuthor Commented:
0
deightonprogCommented:
Not sure, it was a translation I did.

v.busy look into it monday
0
caraf_gAuthor Commented:
Ah, well... I got it!


Nasty code follows

:-)

Had to translate some C to VB
0
caraf_gAuthor Commented:
Option Explicit
Private CRC32tab(0 To 255) As Long
Private Type Shifter1
    MainPart As Long
End Type
Private Type Middle
    B1 As Byte
    B2 As Byte
    B3 As Byte
    B4 As Byte
End Type
Private Type Shifter2
    MainPart As Long
    overflow As Byte
End Type
Public Sub InitialiseCRC32tab()

Dim i As Integer
i = 0
CRC32tab(i) = &H0
i = i + 1
CRC32tab(i) = &H77073096
i = i + 1
CRC32tab(i) = &HEE0E612C
i = i + 1
CRC32tab(i) = &H990951BA
i = i + 1
CRC32tab(i) = &H76DC419
i = i + 1
CRC32tab(i) = &H706AF48F
i = i + 1
CRC32tab(i) = &HE963A535
i = i + 1
CRC32tab(i) = &H9E6495A3
i = i + 1
CRC32tab(i) = &HEDB8832
i = i + 1
CRC32tab(i) = &H79DCB8A4
i = i + 1
CRC32tab(i) = &HE0D5E91E
i = i + 1
CRC32tab(i) = &H97D2D988
i = i + 1
CRC32tab(i) = &H9B64C2B
i = i + 1
CRC32tab(i) = &H7EB17CBD
i = i + 1
CRC32tab(i) = &HE7B82D07
i = i + 1
CRC32tab(i) = &H90BF1D91
i = i + 1
CRC32tab(i) = &H1DB71064
i = i + 1
CRC32tab(i) = &H6AB020F2
i = i + 1
CRC32tab(i) = &HF3B97148
i = i + 1
CRC32tab(i) = &H84BE41DE
i = i + 1
CRC32tab(i) = &H1ADAD47D
i = i + 1
CRC32tab(i) = &H6DDDE4EB
i = i + 1
CRC32tab(i) = &HF4D4B551
i = i + 1
CRC32tab(i) = &H83D385C7
i = i + 1
CRC32tab(i) = &H136C9856
i = i + 1
CRC32tab(i) = &H646BA8C0
i = i + 1
CRC32tab(i) = &HFD62F97A
i = i + 1
CRC32tab(i) = &H8A65C9EC
i = i + 1
CRC32tab(i) = &H14015C4F
i = i + 1
CRC32tab(i) = &H63066CD9
i = i + 1
CRC32tab(i) = &HFA0F3D63
i = i + 1
CRC32tab(i) = &H8D080DF5
i = i + 1
CRC32tab(i) = &H3B6E20C8
i = i + 1
CRC32tab(i) = &H4C69105E
i = i + 1
CRC32tab(i) = &HD56041E4
i = i + 1
CRC32tab(i) = &HA2677172
i = i + 1
CRC32tab(i) = &H3C03E4D1
i = i + 1
CRC32tab(i) = &H4B04D447
i = i + 1
CRC32tab(i) = &HD20D85FD
i = i + 1
CRC32tab(i) = &HA50AB56B
i = i + 1
CRC32tab(i) = &H35B5A8FA
i = i + 1
CRC32tab(i) = &H42B2986C
i = i + 1
CRC32tab(i) = &HDBBBC9D6
i = i + 1
CRC32tab(i) = &HACBCF940
i = i + 1
CRC32tab(i) = &H32D86CE3
i = i + 1
CRC32tab(i) = &H45DF5C75
i = i + 1
CRC32tab(i) = &HDCD60DCF
i = i + 1
CRC32tab(i) = &HABD13D59
i = i + 1
CRC32tab(i) = &H26D930AC
i = i + 1
CRC32tab(i) = &H51DE003A
i = i + 1
CRC32tab(i) = &HC8D75180
i = i + 1
CRC32tab(i) = &HBFD06116
i = i + 1
CRC32tab(i) = &H21B4F4B5
i = i + 1
CRC32tab(i) = &H56B3C423
i = i + 1
CRC32tab(i) = &HCFBA9599
i = i + 1
CRC32tab(i) = &HB8BDA50F
i = i + 1
CRC32tab(i) = &H2802B89E
i = i + 1
CRC32tab(i) = &H5F058808
i = i + 1
CRC32tab(i) = &HC60CD9B2
i = i + 1
CRC32tab(i) = &HB10BE924
i = i + 1
CRC32tab(i) = &H2F6F7C87
i = i + 1
CRC32tab(i) = &H58684C11
i = i + 1
CRC32tab(i) = &HC1611DAB
i = i + 1
CRC32tab(i) = &HB6662D3D
i = i + 1
CRC32tab(i) = &H76DC4190
i = i + 1
CRC32tab(i) = &H1DB7106
i = i + 1
CRC32tab(i) = &H98D220BC
i = i + 1
CRC32tab(i) = &HEFD5102A
i = i + 1
CRC32tab(i) = &H71B18589
i = i + 1
CRC32tab(i) = &H6B6B51F
i = i + 1
CRC32tab(i) = &H9FBFE4A5
i = i + 1
CRC32tab(i) = &HE8B8D433
i = i + 1
CRC32tab(i) = &H7807C9A2
i = i + 1
CRC32tab(i) = &HF00F934
i = i + 1
CRC32tab(i) = &H9609A88E
i = i + 1
CRC32tab(i) = &HE10E9818
i = i + 1
CRC32tab(i) = &H7F6A0DBB
i = i + 1
CRC32tab(i) = &H86D3D2D
i = i + 1
CRC32tab(i) = &H91646C97
i = i + 1
CRC32tab(i) = &HE6635C01
i = i + 1
CRC32tab(i) = &H6B6B51F4
i = i + 1
CRC32tab(i) = &H1C6C6162
i = i + 1
CRC32tab(i) = &H856530D8
i = i + 1
CRC32tab(i) = &HF262004E
i = i + 1
CRC32tab(i) = &H6C0695ED
i = i + 1
CRC32tab(i) = &H1B01A57B
i = i + 1
CRC32tab(i) = &H8208F4C1
i = i + 1
CRC32tab(i) = &HF50FC457
i = i + 1
CRC32tab(i) = &H65B0D9C6
i = i + 1
CRC32tab(i) = &H12B7E950
i = i + 1
CRC32tab(i) = &H8BBEB8EA
i = i + 1
CRC32tab(i) = &HFCB9887C
i = i + 1
CRC32tab(i) = &H62DD1DDF
i = i + 1
CRC32tab(i) = &H15DA2D49
i = i + 1
CRC32tab(i) = &H8CD37CF3
i = i + 1
CRC32tab(i) = &HFBD44C65
i = i + 1
CRC32tab(i) = &H4DB26158
i = i + 1
CRC32tab(i) = &H3AB551CE
i = i + 1
CRC32tab(i) = &HA3BC0074
i = i + 1
CRC32tab(i) = &HD4BB30E2
i = i + 1
CRC32tab(i) = &H4ADFA541
i = i + 1
CRC32tab(i) = &H3DD895D7
i = i + 1
CRC32tab(i) = &HA4D1C46D
i = i + 1
CRC32tab(i) = &HD3D6F4FB
i = i + 1
CRC32tab(i) = &H4369E96A
i = i + 1
CRC32tab(i) = &H346ED9FC
i = i + 1
CRC32tab(i) = &HAD678846
i = i + 1
CRC32tab(i) = &HDA60B8D0
i = i + 1
CRC32tab(i) = &H44042D73
i = i + 1
CRC32tab(i) = &H33031DE5
i = i + 1
CRC32tab(i) = &HAA0A4C5F
i = i + 1
CRC32tab(i) = &HDD0D7CC9
i = i + 1
CRC32tab(i) = &H5005713C
i = i + 1
CRC32tab(i) = &H270241AA
i = i + 1
CRC32tab(i) = &HBE0B1010
i = i + 1
CRC32tab(i) = &HC90C2086
i = i + 1
CRC32tab(i) = &H5768B525
i = i + 1
CRC32tab(i) = &H206F85B3
i = i + 1
CRC32tab(i) = &HB966D409
i = i + 1
CRC32tab(i) = &HCE61E49F
i = i + 1
CRC32tab(i) = &H5EDEF90E
i = i + 1
CRC32tab(i) = &H29D9C998
i = i + 1
CRC32tab(i) = &HB0D09822
i = i + 1
CRC32tab(i) = &HC7D7A8B4
i = i + 1
CRC32tab(i) = &H59B33D17
i = i + 1
CRC32tab(i) = &H2EB40D81
i = i + 1
CRC32tab(i) = &HB7BD5C3B
i = i + 1
CRC32tab(i) = &HC0BA6CAD
i = i + 1
CRC32tab(i) = &HEDB88320
i = i + 1
CRC32tab(i) = &H9ABFB3B6
i = i + 1
CRC32tab(i) = &H3B6E20C
i = i + 1
CRC32tab(i) = &H74B1D29A
i = i + 1
CRC32tab(i) = &HEAD54739
i = i + 1
CRC32tab(i) = &H9DD277AF
i = i + 1
CRC32tab(i) = &H4DB2615
i = i + 1
CRC32tab(i) = &H73DC1683
i = i + 1
CRC32tab(i) = &HE3630B12
i = i + 1
CRC32tab(i) = &H94643B84
i = i + 1
CRC32tab(i) = &HD6D6A3E
i = i + 1
CRC32tab(i) = &H7A6A5AA8
i = i + 1
CRC32tab(i) = &HE40ECF0B
i = i + 1
CRC32tab(i) = &H9309FF9D
i = i + 1
CRC32tab(i) = &HA00AE27
i = i + 1
CRC32tab(i) = &H7D079EB1
i = i + 1
CRC32tab(i) = &HF00F9344
i = i + 1
CRC32tab(i) = &H8708A3D2
i = i + 1
CRC32tab(i) = &H1E01F268
i = i + 1
CRC32tab(i) = &H6906C2FE
i = i + 1
CRC32tab(i) = &HF762575D
i = i + 1
CRC32tab(i) = &H806567CB
i = i + 1
CRC32tab(i) = &H196C3671
i = i + 1
CRC32tab(i) = &H6E6B06E7
i = i + 1
CRC32tab(i) = &HFED41B76
i = i + 1
CRC32tab(i) = &H89D32BE0
i = i + 1
CRC32tab(i) = &H10DA7A5A
i = i + 1
CRC32tab(i) = &H67DD4ACC
i = i + 1
CRC32tab(i) = &HF9B9DF6F
i = i + 1
CRC32tab(i) = &H8EBEEFF9
i = i + 1
CRC32tab(i) = &H17B7BE43
i = i + 1
CRC32tab(i) = &H60B08ED5
i = i + 1
CRC32tab(i) = &HD6D6A3E8
i = i + 1
CRC32tab(i) = &HA1D1937E
i = i + 1
CRC32tab(i) = &H38D8C2C4
i = i + 1
CRC32tab(i) = &H4FDFF252
i = i + 1
CRC32tab(i) = &HD1BB67F1
i = i + 1
CRC32tab(i) = &HA6BC5767
i = i + 1
CRC32tab(i) = &H3FB506DD
i = i + 1
CRC32tab(i) = &H48B2364B
i = i + 1
CRC32tab(i) = &HD80D2BDA
i = i + 1
CRC32tab(i) = &HAF0A1B4C
i = i + 1
CRC32tab(i) = &H36034AF6
i = i + 1
CRC32tab(i) = &H41047A60
i = i + 1
CRC32tab(i) = &HDF60EFC3
i = i + 1
CRC32tab(i) = &HA867DF55
i = i + 1
CRC32tab(i) = &H316E8EEF
i = i + 1
CRC32tab(i) = &H4669BE79
i = i + 1
CRC32tab(i) = &HCB61B38C
i = i + 1
CRC32tab(i) = &HBC66831A
i = i + 1
CRC32tab(i) = &H256FD2A0
i = i + 1
CRC32tab(i) = &H5268E236
i = i + 1
CRC32tab(i) = &HCC0C7795
i = i + 1
CRC32tab(i) = &HBB0B4703
i = i + 1
CRC32tab(i) = &H220216B9
i = i + 1
CRC32tab(i) = &H5505262F
i = i + 1
CRC32tab(i) = &HC5BA3BBE
i = i + 1
CRC32tab(i) = &HB2BD0B28
i = i + 1
CRC32tab(i) = &H2BB45A92
i = i + 1
CRC32tab(i) = &H5CB36A04
i = i + 1
CRC32tab(i) = &HC2D7FFA7
i = i + 1
CRC32tab(i) = &HB5D0CF31
i = i + 1
CRC32tab(i) = &H2CD99E8B
i = i + 1
CRC32tab(i) = &H5BDEAE1D
i = i + 1
CRC32tab(i) = &H9B64C2B0
i = i + 1
CRC32tab(i) = &HEC63F226
i = i + 1
CRC32tab(i) = &H756AA39C
i = i + 1
CRC32tab(i) = &H26D930A
i = i + 1
CRC32tab(i) = &H9C0906A9
i = i + 1
CRC32tab(i) = &HEB0E363F
i = i + 1
CRC32tab(i) = &H72076785
i = i + 1
CRC32tab(i) = &H5005713
i = i + 1
CRC32tab(i) = &H95BF4A82
i = i + 1
CRC32tab(i) = &HE2B87A14
i = i + 1
CRC32tab(i) = &H7BB12BAE
i = i + 1
CRC32tab(i) = &HCB61B38
i = i + 1
CRC32tab(i) = &H92D28E9B
i = i + 1
CRC32tab(i) = &HE5D5BE0D
i = i + 1
CRC32tab(i) = &H7CDCEFB7
i = i + 1
CRC32tab(i) = &HBDBDF21
i = i + 1
CRC32tab(i) = &H86D3D2D4
i = i + 1
CRC32tab(i) = &HF1D4E242
i = i + 1
CRC32tab(i) = &H68DDB3F8
i = i + 1
CRC32tab(i) = &H1FDA836E
i = i + 1
CRC32tab(i) = &H81BE16CD
i = i + 1
CRC32tab(i) = &HF6B9265B
i = i + 1
CRC32tab(i) = &H6FB077E1
i = i + 1
CRC32tab(i) = &H18B74777
i = i + 1
CRC32tab(i) = &H88085AE6
i = i + 1
CRC32tab(i) = &HFF0F6A70
i = i + 1
CRC32tab(i) = &H66063BCA
i = i + 1
CRC32tab(i) = &H11010B5C
i = i + 1
CRC32tab(i) = &H8F659EFF
i = i + 1
CRC32tab(i) = &HF862AE69
i = i + 1
CRC32tab(i) = &H616BFFD3
i = i + 1
CRC32tab(i) = &H166CCF45
i = i + 1
CRC32tab(i) = &HA00AE278
i = i + 1
CRC32tab(i) = &HD70DD2EE
i = i + 1
CRC32tab(i) = &H4E048354
i = i + 1
CRC32tab(i) = &H3903B3C2
i = i + 1
CRC32tab(i) = &HA7672661
i = i + 1
CRC32tab(i) = &HD06016F7
i = i + 1
CRC32tab(i) = &H4969474D
i = i + 1
CRC32tab(i) = &H3E6E77DB
i = i + 1
CRC32tab(i) = &HAED16A4A
i = i + 1
CRC32tab(i) = &HD9D65ADC
i = i + 1
CRC32tab(i) = &H40DF0B66
i = i + 1
CRC32tab(i) = &H37D83BF0
i = i + 1
CRC32tab(i) = &HA9BCAE53
i = i + 1
CRC32tab(i) = &HDEBB9EC5
i = i + 1
CRC32tab(i) = &H47B2CF7F
i = i + 1
CRC32tab(i) = &H30B5FFE9
i = i + 1
CRC32tab(i) = &HBDBDF21C
i = i + 1
CRC32tab(i) = &HCABAC28A
i = i + 1
CRC32tab(i) = &H53B39330
i = i + 1
CRC32tab(i) = &H24B4A3A6
i = i + 1
CRC32tab(i) = &HBAD03605
i = i + 1
CRC32tab(i) = &HCDD70693
i = i + 1
CRC32tab(i) = &H54DE5729
i = i + 1
CRC32tab(i) = &H23D967BF
i = i + 1
CRC32tab(i) = &HB3667A2E
i = i + 1
CRC32tab(i) = &HC4614AB8
i = i + 1
CRC32tab(i) = &H5D681B02
i = i + 1
CRC32tab(i) = &H2A6F2B94
i = i + 1
CRC32tab(i) = &HB40BBE37
i = i + 1
CRC32tab(i) = &HC30C8EA1
i = i + 1
CRC32tab(i) = &H5A05DF1B
i = i + 1
CRC32tab(i) = &H2D02EF8D

End Sub
Private Function RightShiftEight(ByVal lngOriginal As Long) As Long

Dim S1 As Shifter1
Dim M As Middle

S1.MainPart = lngOriginal
LSet M = S1
M.B1 = M.B2
M.B2 = M.B3
M.B3 = M.B4
M.B4 = 0
LSet S1 = M
RightShiftEight = S1.MainPart

End Function
Private Function CRC32Byte(ByVal bytNext As Byte, ByVal lngWork As Long) As Long

CRC32Byte = CRC32tab(CByte(&HFF And (lngWork Xor CLng(bytNext)))) Xor (RightShiftEight(lngWork) And &HFFFFFF)

End Function
Private Function CRC32End(lngWork As Long) As Long

CRC32End = lngWork Xor &HFFFFFFFF

End Function
Public Function GetCRC32ForByteArray(bytes() As Byte) As Long

Dim lngWork As Long
Dim lngCounter As Long


lngWork = &HFFFFFFFF
For lngCounter = LBound(bytes) To UBound(bytes)
    lngWork = CRC32Byte(bytes(lngCounter), lngWork)
Next

GetCRC32ForByteArray = CRC32End(lngWork)


End Function
0
mcriderCommented:
Too bad you can't award yourself points...

Cheers!
0
caraf_gAuthor Commented:
I've asked CS to make it a PAQ though. Thought it might come in handy.
:-)
0
The_EE_ManCommented:
Caraf_g has provided the answer to this question.  I am PAQ'ing it for the archives.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
caraf_gAuthor Commented:
For anyone who's interested I managed to massively improve speed with the following code:


Option Explicit
Private CRC32tab(0 To 255) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, _
                                                                     ByVal Source As Long, _
                                                                     ByVal Length As Long)
Private l2(0 To 1) As Long
Private lngResult As Long
Private lngL2 As Long

Private lngWork2 As Long
Private lngWorkP As Long
Public Sub InitialiseCRC32tab()

lngL2 = VarPtr(l2(0)) + 1
lngWorkP = VarPtr(lngWork2)

Dim i As Integer
i = 0
CRC32tab(i) = &H0
i = i + 1
CRC32tab(i) = &H77073096
i = i + 1
CRC32tab(i) = &HEE0E612C
i = i + 1
CRC32tab(i) = &H990951BA
i = i + 1
CRC32tab(i) = &H76DC419
i = i + 1
CRC32tab(i) = &H706AF48F
i = i + 1
CRC32tab(i) = &HE963A535
i = i + 1
CRC32tab(i) = &H9E6495A3
i = i + 1
CRC32tab(i) = &HEDB8832
i = i + 1
CRC32tab(i) = &H79DCB8A4
i = i + 1
CRC32tab(i) = &HE0D5E91E
i = i + 1
CRC32tab(i) = &H97D2D988
i = i + 1
CRC32tab(i) = &H9B64C2B
i = i + 1
CRC32tab(i) = &H7EB17CBD
i = i + 1
CRC32tab(i) = &HE7B82D07
i = i + 1
CRC32tab(i) = &H90BF1D91
i = i + 1
CRC32tab(i) = &H1DB71064
i = i + 1
CRC32tab(i) = &H6AB020F2
i = i + 1
CRC32tab(i) = &HF3B97148
i = i + 1
CRC32tab(i) = &H84BE41DE
i = i + 1
CRC32tab(i) = &H1ADAD47D
i = i + 1
CRC32tab(i) = &H6DDDE4EB
i = i + 1
CRC32tab(i) = &HF4D4B551
i = i + 1
CRC32tab(i) = &H83D385C7
i = i + 1
CRC32tab(i) = &H136C9856
i = i + 1
CRC32tab(i) = &H646BA8C0
i = i + 1
CRC32tab(i) = &HFD62F97A
i = i + 1
CRC32tab(i) = &H8A65C9EC
i = i + 1
CRC32tab(i) = &H14015C4F
i = i + 1
CRC32tab(i) = &H63066CD9
i = i + 1
CRC32tab(i) = &HFA0F3D63
i = i + 1
CRC32tab(i) = &H8D080DF5
i = i + 1
CRC32tab(i) = &H3B6E20C8
i = i + 1
CRC32tab(i) = &H4C69105E
i = i + 1
CRC32tab(i) = &HD56041E4
i = i + 1
CRC32tab(i) = &HA2677172
i = i + 1
CRC32tab(i) = &H3C03E4D1
i = i + 1
CRC32tab(i) = &H4B04D447
i = i + 1
CRC32tab(i) = &HD20D85FD
i = i + 1
CRC32tab(i) = &HA50AB56B
i = i + 1
CRC32tab(i) = &H35B5A8FA
i = i + 1
CRC32tab(i) = &H42B2986C
i = i + 1
CRC32tab(i) = &HDBBBC9D6
i = i + 1
CRC32tab(i) = &HACBCF940
i = i + 1
CRC32tab(i) = &H32D86CE3
i = i + 1
CRC32tab(i) = &H45DF5C75
i = i + 1
CRC32tab(i) = &HDCD60DCF
i = i + 1
CRC32tab(i) = &HABD13D59
i = i + 1
CRC32tab(i) = &H26D930AC
i = i + 1
CRC32tab(i) = &H51DE003A
i = i + 1
CRC32tab(i) = &HC8D75180
i = i + 1
CRC32tab(i) = &HBFD06116
i = i + 1
CRC32tab(i) = &H21B4F4B5
i = i + 1
CRC32tab(i) = &H56B3C423
i = i + 1
CRC32tab(i) = &HCFBA9599
i = i + 1
CRC32tab(i) = &HB8BDA50F
i = i + 1
CRC32tab(i) = &H2802B89E
i = i + 1
CRC32tab(i) = &H5F058808
i = i + 1
CRC32tab(i) = &HC60CD9B2
i = i + 1
CRC32tab(i) = &HB10BE924
i = i + 1
CRC32tab(i) = &H2F6F7C87
i = i + 1
CRC32tab(i) = &H58684C11
i = i + 1
CRC32tab(i) = &HC1611DAB
i = i + 1
CRC32tab(i) = &HB6662D3D
i = i + 1
CRC32tab(i) = &H76DC4190
i = i + 1
CRC32tab(i) = &H1DB7106
i = i + 1
CRC32tab(i) = &H98D220BC
i = i + 1
CRC32tab(i) = &HEFD5102A
i = i + 1
CRC32tab(i) = &H71B18589
i = i + 1
CRC32tab(i) = &H6B6B51F
i = i + 1
CRC32tab(i) = &H9FBFE4A5
i = i + 1
CRC32tab(i) = &HE8B8D433
i = i + 1
CRC32tab(i) = &H7807C9A2
i = i + 1
CRC32tab(i) = &HF00F934
i = i + 1
CRC32tab(i) = &H9609A88E
i = i + 1
CRC32tab(i) = &HE10E9818
i = i + 1
CRC32tab(i) = &H7F6A0DBB
i = i + 1
CRC32tab(i) = &H86D3D2D
i = i + 1
CRC32tab(i) = &H91646C97
i = i + 1
CRC32tab(i) = &HE6635C01
i = i + 1
CRC32tab(i) = &H6B6B51F4
i = i + 1
CRC32tab(i) = &H1C6C6162
i = i + 1
CRC32tab(i) = &H856530D8
i = i + 1
CRC32tab(i) = &HF262004E
i = i + 1
CRC32tab(i) = &H6C0695ED
i = i + 1
CRC32tab(i) = &H1B01A57B
i = i + 1
CRC32tab(i) = &H8208F4C1
i = i + 1
CRC32tab(i) = &HF50FC457
i = i + 1
CRC32tab(i) = &H65B0D9C6
i = i + 1
CRC32tab(i) = &H12B7E950
i = i + 1
CRC32tab(i) = &H8BBEB8EA
i = i + 1
CRC32tab(i) = &HFCB9887C
i = i + 1
CRC32tab(i) = &H62DD1DDF
i = i + 1
CRC32tab(i) = &H15DA2D49
i = i + 1
CRC32tab(i) = &H8CD37CF3
i = i + 1
CRC32tab(i) = &HFBD44C65
i = i + 1
CRC32tab(i) = &H4DB26158
i = i + 1
CRC32tab(i) = &H3AB551CE
i = i + 1
CRC32tab(i) = &HA3BC0074
i = i + 1
CRC32tab(i) = &HD4BB30E2
i = i + 1
CRC32tab(i) = &H4ADFA541
i = i + 1
CRC32tab(i) = &H3DD895D7
i = i + 1
CRC32tab(i) = &HA4D1C46D
i = i + 1
CRC32tab(i) = &HD3D6F4FB
i = i + 1
CRC32tab(i) = &H4369E96A
i = i + 1
CRC32tab(i) = &H346ED9FC
i = i + 1
CRC32tab(i) = &HAD678846
i = i + 1
CRC32tab(i) = &HDA60B8D0
i = i + 1
CRC32tab(i) = &H44042D73
i = i + 1
CRC32tab(i) = &H33031DE5
i = i + 1
CRC32tab(i) = &HAA0A4C5F
i = i + 1
CRC32tab(i) = &HDD0D7CC9
i = i + 1
CRC32tab(i) = &H5005713C
i = i + 1
CRC32tab(i) = &H270241AA
i = i + 1
CRC32tab(i) = &HBE0B1010
i = i + 1
CRC32tab(i) = &HC90C2086
i = i + 1
CRC32tab(i) = &H5768B525
i = i + 1
CRC32tab(i) = &H206F85B3
i = i + 1
CRC32tab(i) = &HB966D409
i = i + 1
CRC32tab(i) = &HCE61E49F
i = i + 1
CRC32tab(i) = &H5EDEF90E
i = i + 1
CRC32tab(i) = &H29D9C998
i = i + 1
CRC32tab(i) = &HB0D09822
i = i + 1
CRC32tab(i) = &HC7D7A8B4
i = i + 1
CRC32tab(i) = &H59B33D17
i = i + 1
CRC32tab(i) = &H2EB40D81
i = i + 1
CRC32tab(i) = &HB7BD5C3B
i = i + 1
CRC32tab(i) = &HC0BA6CAD
i = i + 1
CRC32tab(i) = &HEDB88320
i = i + 1
CRC32tab(i) = &H9ABFB3B6
i = i + 1
CRC32tab(i) = &H3B6E20C
i = i + 1
CRC32tab(i) = &H74B1D29A
i = i + 1
CRC32tab(i) = &HEAD54739
i = i + 1
CRC32tab(i) = &H9DD277AF
i = i + 1
CRC32tab(i) = &H4DB2615
i = i + 1
CRC32tab(i) = &H73DC1683
i = i + 1
CRC32tab(i) = &HE3630B12
i = i + 1
CRC32tab(i) = &H94643B84
i = i + 1
CRC32tab(i) = &HD6D6A3E
i = i + 1
CRC32tab(i) = &H7A6A5AA8
i = i + 1
CRC32tab(i) = &HE40ECF0B
i = i + 1
CRC32tab(i) = &H9309FF9D
i = i + 1
CRC32tab(i) = &HA00AE27
i = i + 1
CRC32tab(i) = &H7D079EB1
i = i + 1
CRC32tab(i) = &HF00F9344
i = i + 1
CRC32tab(i) = &H8708A3D2
i = i + 1
CRC32tab(i) = &H1E01F268
i = i + 1
CRC32tab(i) = &H6906C2FE
i = i + 1
CRC32tab(i) = &HF762575D
i = i + 1
CRC32tab(i) = &H806567CB
i = i + 1
CRC32tab(i) = &H196C3671
i = i + 1
CRC32tab(i) = &H6E6B06E7
i = i + 1
CRC32tab(i) = &HFED41B76
i = i + 1
CRC32tab(i) = &H89D32BE0
i = i + 1
CRC32tab(i) = &H10DA7A5A
i = i + 1
CRC32tab(i) = &H67DD4ACC
i = i + 1
CRC32tab(i) = &HF9B9DF6F
i = i + 1
CRC32tab(i) = &H8EBEEFF9
i = i + 1
CRC32tab(i) = &H17B7BE43
i = i + 1
CRC32tab(i) = &H60B08ED5
i = i + 1
CRC32tab(i) = &HD6D6A3E8
i = i + 1
CRC32tab(i) = &HA1D1937E
i = i + 1
CRC32tab(i) = &H38D8C2C4
i = i + 1
CRC32tab(i) = &H4FDFF252
i = i + 1
CRC32tab(i) = &HD1BB67F1
i = i + 1
CRC32tab(i) = &HA6BC5767
i = i + 1
CRC32tab(i) = &H3FB506DD
i = i + 1
CRC32tab(i) = &H48B2364B
i = i + 1
CRC32tab(i) = &HD80D2BDA
i = i + 1
CRC32tab(i) = &HAF0A1B4C
i = i + 1
CRC32tab(i) = &H36034AF6
i = i + 1
CRC32tab(i) = &H41047A60
i = i + 1
CRC32tab(i) = &HDF60EFC3
i = i + 1
CRC32tab(i) = &HA867DF55
i = i + 1
CRC32tab(i) = &H316E8EEF
i = i + 1
CRC32tab(i) = &H4669BE79
i = i + 1
CRC32tab(i) = &HCB61B38C
i = i + 1
CRC32tab(i) = &HBC66831A
i = i + 1
CRC32tab(i) = &H256FD2A0
i = i + 1
CRC32tab(i) = &H5268E236
i = i + 1
CRC32tab(i) = &HCC0C7795
i = i + 1
CRC32tab(i) = &HBB0B4703
i = i + 1
CRC32tab(i) = &H220216B9
i = i + 1
CRC32tab(i) = &H5505262F
i = i + 1
CRC32tab(i) = &HC5BA3BBE
i = i + 1
CRC32tab(i) = &HB2BD0B28
i = i + 1
CRC32tab(i) = &H2BB45A92
i = i + 1
CRC32tab(i) = &H5CB36A04
i = i + 1
CRC32tab(i) = &HC2D7FFA7
i = i + 1
CRC32tab(i) = &HB5D0CF31
i = i + 1
CRC32tab(i) = &H2CD99E8B
i = i + 1
CRC32tab(i) = &H5BDEAE1D
i = i + 1
CRC32tab(i) = &H9B64C2B0
i = i + 1
CRC32tab(i) = &HEC63F226
i = i + 1
CRC32tab(i) = &H756AA39C
i = i + 1
CRC32tab(i) = &H26D930A
i = i + 1
CRC32tab(i) = &H9C0906A9
i = i + 1
CRC32tab(i) = &HEB0E363F
i = i + 1
CRC32tab(i) = &H72076785
i = i + 1
CRC32tab(i) = &H5005713
i = i + 1
CRC32tab(i) = &H95BF4A82
i = i + 1
CRC32tab(i) = &HE2B87A14
i = i + 1
CRC32tab(i) = &H7BB12BAE
i = i + 1
CRC32tab(i) = &HCB61B38
i = i + 1
CRC32tab(i) = &H92D28E9B
i = i + 1
CRC32tab(i) = &HE5D5BE0D
i = i + 1
CRC32tab(i) = &H7CDCEFB7
i = i + 1
CRC32tab(i) = &HBDBDF21
i = i + 1
CRC32tab(i) = &H86D3D2D4
i = i + 1
CRC32tab(i) = &HF1D4E242
i = i + 1
CRC32tab(i) = &H68DDB3F8
i = i + 1
CRC32tab(i) = &H1FDA836E
i = i + 1
CRC32tab(i) = &H81BE16CD
i = i + 1
CRC32tab(i) = &HF6B9265B
i = i + 1
CRC32tab(i) = &H6FB077E1
i = i + 1
CRC32tab(i) = &H18B74777
i = i + 1
CRC32tab(i) = &H88085AE6
i = i + 1
CRC32tab(i) = &HFF0F6A70
i = i + 1
CRC32tab(i) = &H66063BCA
i = i + 1
CRC32tab(i) = &H11010B5C
i = i + 1
CRC32tab(i) = &H8F659EFF
i = i + 1
CRC32tab(i) = &HF862AE69
i = i + 1
CRC32tab(i) = &H616BFFD3
i = i + 1
CRC32tab(i) = &H166CCF45
i = i + 1
CRC32tab(i) = &HA00AE278
i = i + 1
CRC32tab(i) = &HD70DD2EE
i = i + 1
CRC32tab(i) = &H4E048354
i = i + 1
CRC32tab(i) = &H3903B3C2
i = i + 1
CRC32tab(i) = &HA7672661
i = i + 1
CRC32tab(i) = &HD06016F7
i = i + 1
CRC32tab(i) = &H4969474D
i = i + 1
CRC32tab(i) = &H3E6E77DB
i = i + 1
CRC32tab(i) = &HAED16A4A
i = i + 1
CRC32tab(i) = &HD9D65ADC
i = i + 1
CRC32tab(i) = &H40DF0B66
i = i + 1
CRC32tab(i) = &H37D83BF0
i = i + 1
CRC32tab(i) = &HA9BCAE53
i = i + 1
CRC32tab(i) = &HDEBB9EC5
i = i + 1
CRC32tab(i) = &H47B2CF7F
i = i + 1
CRC32tab(i) = &H30B5FFE9
i = i + 1
CRC32tab(i) = &HBDBDF21C
i = i + 1
CRC32tab(i) = &HCABAC28A
i = i + 1
CRC32tab(i) = &H53B39330
i = i + 1
CRC32tab(i) = &H24B4A3A6
i = i + 1
CRC32tab(i) = &HBAD03605
i = i + 1
CRC32tab(i) = &HCDD70693
i = i + 1
CRC32tab(i) = &H54DE5729
i = i + 1
CRC32tab(i) = &H23D967BF
i = i + 1
CRC32tab(i) = &HB3667A2E
i = i + 1
CRC32tab(i) = &HC4614AB8
i = i + 1
CRC32tab(i) = &H5D681B02
i = i + 1
CRC32tab(i) = &H2A6F2B94
i = i + 1
CRC32tab(i) = &HB40BBE37
i = i + 1
CRC32tab(i) = &HC30C8EA1
i = i + 1
CRC32tab(i) = &H5A05DF1B
i = i + 1
CRC32tab(i) = &H2D02EF8D

End Sub
Private Function CRC32ByteAlternative(ByVal bytNext As Byte) As Long

CopyMemory lngWorkP, lngL2, 4
CRC32ByteAlternative = CRC32tab(CByte(&HFF And (l2(0) Xor CLng(bytNext)))) Xor (lngWork2 And &HFFFFFF)

End Function
Private Function CRC32End(lngWork As Long) As Long

CRC32End = lngWork Xor &HFFFFFFFF

End Function
Public Function GetCRC32ForByteArray(bytes() As Byte) As Long

Dim lngTest As Long
Dim lngWork As Long
Dim lngCounter As Long

l2(0) = &HFFFFFFFF
For lngCounter = LBound(bytes) To UBound(bytes)
    CopyMemory lngWorkP, lngL2, 4
    l2(0) = CRC32tab(&HFF And (l2(0) Xor CLng(bytes(lngCounter)))) Xor (lngWork2 And &HFFFFFF)
Next

GetCRC32ForByteArray = CRC32End(l2(0))

End Function
0
caraf_gAuthor Commented:
Function CRC32ByteAlternative can be removed as the code has been brought inline to GetCRC32ForByteArray.
0
plasmatekCommented:
This is just what I needed as well. Thanks very much.
0
caraf_gAuthor Commented:
Glad I could help ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.