Public CRCstring As String
Public Function StringCRC32Hex() As String
Dim Res As Long
Res = StringCRC32()
StringCRC32Hex = Hexn(Res, 4)
End Function
Public Function StringCRC32() As Long
Dim Res As Long, slen As String, i As Integer
Res = 0
slen = Len(CRCstring)
For i = 1 To slen
Res = UpdateCRC32(Asc(Mid(CRCstring, i, 1)), Res)
Next i
StringCRC32 = Res
End Function
Private Function UpdateCRC32(Octet As Byte, CRC As Long) As Long
Dim crc1 As Long, crc2 As Long, datal As Long
Dim Index As Integer
datal = Octet
crc1 = CRC Xor datal
crc2 = CRC / 256
crc2 = crc2 And &HFFFFFF
Index = crc1 And 255
UpdateCRC32 = TabCRC32(Index) Xor crc2
End Function
Function Hexn(lData As Long, iLen As Integer) As String
Dim Res As String, Tempstr As String, nb As Integer
Res = Hex(lData)
nb = iLen - Len(Res)
If nb > 0 Then
Tempstr = String$(nb, 48)
Res = Tempstr & Res
End If
If Len(Res) > iLen Then Res = Right$(Res, iLen)
Hexn = Res
End Function