Results 1 to 8 of 8

Thread: md5 hash of a whole file RESOLVED

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    27

    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
    Last edited by Usul; Jul 30th, 2004 at 07:25 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width