Feedback

VB - MD5-Hash einer Datei

Veröffentlicht von am 6/12/2012
(0 Bewertungen)
Public Function MD5FromFile(ByVal sFile As String) As String
        Dim MD5 As New MD5CryptoServiceProvider
        Dim Hash As Byte()
        Dim Result As String = ""
        Dim Tmp As String = ""

        Dim FN As New FileStream(sFile, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
        MD5.ComputeHash(FN)
        FN.Close()

        Hash = MD5.Hash
        For i As Integer = 0 To Hash.Length - 1
            Tmp = Hex(Hash(i))
            If Len(Tmp) = 1 Then Tmp = "0" & Tmp
            Result += Tmp
        Next
        Return Result
    End Function
Abgelegt unter md5, datei, hash, file, vb, nuvolox, software, filestream, function, public.

Kommentare zum Snippet

 

Logge dich ein, um hier zu kommentieren!