- 积分
- 5952
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-8-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
直接上代码!!
- 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
复制代码
|
评分
-
查看全部评分
|