It works well for the breakdance.avi file, and I tried few movie files and succeeded in identifying them with the produced hash.
It didn't worked for the dummy.rar file provided, It produces a different hashe than the one provided in the website...
But the C code given in the website also fails to produce hash code for dummy.rar file too...
And to my relief The C code and my vb code produces the same hash for the dummy.rar file, So i'm posting the code here anyway...
There may be better implementations.... post them as comments please....
- Code: Select all
Function find_Hash(path As String) As String
On Error GoTo ErrM:
Dim fl As Long
Dim fsize As Variant
Dim byteArray(7) As Byte
Dim intArray(7) As Long
Dim Hash As String
fl = FreeFile()
For j = 0 To 7
intArray(j) = 0
Next
fsize = FileLen(path)
Open path For Binary As #fl
Seek #fl, 1
For i = 0 To 8191
Get #fl, , byteArray
For j = 0 To 7
intArray(j) = intArray(j) + byteArray(j)
Next
Next
If (fsize - 65536 + 1) > 0 Then
Seek #fl, fsize - 65536 + 1
Else
Seek #fl, 1
End If
For i = 0 To 8191
Get #fl, , byteArray
For j = 0 To 7
intArray(j) = intArray(j) + byteArray(j)
Next
Next
Close #fl
For i = 0 To 7
intArray(i) = intArray(i) + fsize Mod 256
fsize = fsize \ 256
Next
For i = 0 To 6
intArray(i + 1) = intArray(i + 1) + (intArray(i) \ 256)
Next
For i = 0 To 7
byteArray(i) = CByte(intArray(i) Mod 256)
Next
Hash = ""
For i = 7 To 0 Step -1
If Len(Hex(byteArray(i))) < 2 Then
Hash = Hash & "0" & Hex(byteArray(i))
Else
Hash = Hash & Hex(byteArray(i))
End If
Next
Hash = LCase(Hash)
find_Hash = Hash
Exit Function
ErrM:
find_Hash = 0
End Function


