md5 hash of a whole file RESOLVED
Well, how can I get the md5 hashvalue of a whole file?
I only found how to encrypt strings in the web, but nothing about whole files.
I tried it myself, but the result is not the same as when I use a freeware programm (and I assume the error is in MY code):
Code:
Private Sub testHash(ByVal filepath As System.String)
Dim hashvalue As String
Dim inputStream As FileStream
inputStream = File.OpenRead(filepath)
Dim tmpSource(1024) As Byte
Dim tmpHash() As Byte
inputStream.Read(tmpSource, 0, tmpSource.Length)
tmpHash = New MD5CryptoServiceProvider().ComputeHash(tmpSource)
Dim i As Integer
Dim sOutput As New StringBuilder(tmpHash.Length)
For i = 0 To tmpHash.Length - 1
sOutput.Append(tmpHash(i).ToString("X2"))
Next
hashvalue = sOutput.ToString()
inputStream.Close()
MessageBox.Show(hashvalue)
End Sub
any help appreciated,
thanx
Usul