Hi all,
I have a function which is in both a DLL on my website and in an EXE locally, the function gets the hash of a file, requests a hash of a file from the website (using the dll) and if they are different updates the website file. However even when I know the file is an exact copy the hashes are both different!!!
Here's my function: (it requires CAPICOM v2.0)
VB Code:
Private Function HashFile(filename As String) As String Const lngChunkSize = 100000 Dim theHash As CAPICOM.HashedData Dim lngFreeFile As Long Dim strChunk As String Set theHash = New CAPICOM.HashedData theHash.Algorithm = CAPICOM_HASH_ALGORITHM_MD5 lngFreeFile = FreeFile Open filename For Binary Access Read As lngFreeFile Do If lngChunkSize > LOF(lngFreeFile) - Loc(lngFreeFile) Then strChunk = Space$(LOF(lngFreeFile) - Loc(lngFreeFile)) Else strChunk = Space$(lngChunkSize) End If Get lngFreeFile, , strChunk theHash.Hash strChunk Loop Until Loc(lngFreeFile) = LOF(lngFreeFile) Close lngFreeFile HashFile = theHash.Value Set theHash = Nothing End Function




Reply With Quote