|
-
Mar 4th, 2008, 07:56 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] CAPICOM Hash returning different values
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
Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White
-
Mar 4th, 2008, 08:38 AM
#2
Thread Starter
Hyperactive Member
Re: CAPICOM Hash returning different values
http://www.mcse.ms/message1672489.html
I've just found this article which seems to describe the problem perfectly and puts it down to string encoding, is there something I could do using StrConv?
Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White
-
Mar 4th, 2008, 09:20 AM
#3
Thread Starter
Hyperactive Member
Re: CAPICOM Hash returning different values
Doesnt matter, turns out I was calculating the filename incorrectly before calling the function.
Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|