📄 check_crc32.bas
字号:
Attribute VB_Name = "Check_CRC32"
Option Explicit
'This module calculates the CRC32-checksum of a certain bytestream
Dim CrcTableInit As Boolean
Dim CRCTable(0 To 255) As Long
Public Function calcCRC32(ByteArray() As Byte) As Long
Dim i As Long
Dim crc As Long
If CrcTableInit = False Then Call Init_CRCTable
crc = -1
For i = 0 To UBound(ByteArray) - 1
crc = (((crc And &HFFFFFF00) \ &H100) And &HFFFFFF) Xor (CRCTable((crc And &HFF) Xor ByteArray(i)))
Next i
crc = crc Xor &HFFFFFFFF
calcCRC32 = crc
End Function
Private Sub Init_CRCTable()
Dim i As Long
Dim j As Long
Dim Limit As Long
Dim crc As Long
Limit = &HEDB88320
For i = 0 To 255
crc = i
For j = 0 To 7
If crc And 1 Then
crc = (((crc And &HFFFFFFFE) \ 2) And &H7FFFFFFF) Xor Limit
Else
crc = ((crc And &HFFFFFFFE) \ 2) And &H7FFFFFFF
End If
Next j
CRCTable(i) = crc
Next i
CrcTableInit = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -