|
-
Jun 20th, 2005, 11:57 AM
#1
Calculate MD5 hash of a file [resolved]
I need to calculate MD5 hash value of a file. I've been searching around but with no luck.
Anyone have any pointers or ideas?
Last edited by baja_yu; Jun 20th, 2005 at 01:00 PM.
-
Jun 20th, 2005, 12:23 PM
#2
Re: Calculate MD5 hash of a file
Should I give you the full code ? or should I give you the MD5 class, and you'll take it from there ?
-
Jun 20th, 2005, 12:30 PM
#3
Re: Calculate MD5 hash of a file
Anyway is fine with me
-
Jun 20th, 2005, 12:42 PM
#4
Re: Calculate MD5 hash of a file
Here:
VB Code:
Option Explicit
Private Function GetFileMD5(ByVal FileName As String) As String
Dim MD5 As New clsMD5, FF As Integer, Buff() As Byte
Const BuffSize As Long = 2 ^ 16 ' (64 KBytes)
On Error GoTo ErrExit
FF = FreeFile
Open FileName For Binary Access Read As FF
MD5.MD5Init
Do Until Loc(FF) >= LOF(FF)
If Loc(FF) + BuffSize > LOF(FF) Then
ReDim Buff(LOF(FF) - Loc(FF) - 1)
Else
ReDim Buff(BuffSize - 1)
End If
Get FF, , Buff
MD5.MD5Update UBound(Buff) + 1, Buff
Loop
MD5.MD5Final
GetFileMD5 = MD5.GetValues
Close FF
Exit Function
ErrExit:
Err.Clear
GetFileMD5 = ""
End Function
Private Sub Form_Load()
Debug.Print GetFileMD5("C:\Test_001.wav")
End Sub
-
Jun 20th, 2005, 12:53 PM
#5
Re: Calculate MD5 hash of a file
Hehe
VB Code:
Private Sub Form_Load()
Dim MD5 As New clsMD5
Debug.Print MD5.DigestFileToHexStr("C:\Test_001.wav")
End Sub
I just noticed, the class does it for you (DigestFileToHexStr...)
[edit]
Well, at least with my code you can add a progress bar to it
-
Jun 20th, 2005, 12:56 PM
#6
Re: Calculate MD5 hash of a file
works great! Thanks
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
|