Dim CRC32Table(255) As Long Private Sub Command1_Click() MsgBox crc32str("sysdzw") a = crc32file("c:/1.jpg") b = crc32file("c:/2.jpg") If (a & b <> "") And a = b Then MsgBox "same" End Sub 'string's CRC32 Public Function crc32str(ByVal item As String) As String Dim i As Long,iCRC As Long,lngA As Long,ret As Long Dim b() As Byte,bytT As Byte,bytC As Byte b = StrConv(item,vbFromUnicode) InitCrc32 iCRC = &HFFFFFFFF For i = 0 To UBound(b) bytC = b(i) bytT = (iCRC And &HFF) Xor bytC lngA = ((iCRC And &HFFFFFF00) / &H100) And &HFFFFFF iCRC = lngA Xor CRC32Table(bytT) Next ret = iCRC Xor &HFFFFFFFF crc32str = Right("00000000" & Hex(ret),8) End Function 'file's CRC32 Public Function crc32file(sFilePath As String,Optional Block As Long = 1024) As String Dim hFile As Long,i As Long,Size As Long,ret As Long,t As Long,n As Long Dim bytT As Byte,bytC As Byte Dim sSize As Currency,total As Currency If Len(Dir(sFilePath)) = 0 Then Exit Function InitCrc32 iCRC = &HFFFFFFFF total = FileLen(sFilePath) If total < 0 Then total = total + 256 ^ 4 sSize = Block * 1024 t = Int((total - 1) / sSize) + 1 hFile = FreeFile Open sFilePath For Binary Access Read As #hFile While total > 0 If total >= sSize Then Size = sSize Else Size = total ReDim b(Size - 1) As Byte Get #hFile,b For i = 0 To UBound(b) bytC = b(i) bytT = (iCRC And &HFF) Xor bytC lngA = ((iCRC And &HFFFFFF00) / &H100) And &HFFFFFF iCRC = lngA Xor CRC32Table(bytT) Next total = total - sSize: n = n + 1 Wend Close #hFile ret = iCRC Xor &HFFFFFFFF crc32file = Right("00000000" & Hex(ret),8) End Function 'CRC32 Table Public Function InitCrc32(Optional ByVal Seed As Long = &HEDB88320,Optional ByVal Precondition As Long = &HFFFFFFFF) As Long Dim i As Integer,j As Integer,Crc32 As Long,Temp As Long For i = 0 To 255 Crc32 = i For j = 0 To 7 Temp = ((Crc32 And &HFFFFFFFE) / &H2) And &H7FFFFFFF If (Crc32 And &H1) Then Crc32 = Temp Xor Seed Else Crc32 = Temp Next CRC32Table(i) = Crc32 Next InitCrc32 = Precondition End Function