Imports System.IO Imports System.Text Imports System.Diagnostics Imports System.Security.Cryptography Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim stopwatch As New Stopwatch Dim md5 As String = "" stopwatch.Start() md5 = GetMD5Checksum("C:\windows\explorer.exe") stopwatch.Stop() MsgBox("MD5 Checksum [" + md5 + "]" & Environment.NewLine & _ "Computed in " + stopwatch.Elapsed.ToString) End Sub 'Button1_Click Public Function GetMD5Checksum(ByVal filePath As String) As String Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider Dim fs As FileStream = New FileStream(filePath, FileMode.Open, _ FileAccess.Read, FileShare.Read, 8192) fs = New FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, 8192) md5.ComputeHash(fs) fs.Close() Dim hash As Byte() = md5.Hash Dim sb As StringBuilder =NewStringBuilder Dim hByte As Byte For Each hByte In hash sb.Append(String.Format _ "{0:X2}", hByte)) Next Return sb.ToString() End Function 'GetMD5Checksum
System.Windows.Forms.Form
System.Windows.Forms.Control
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)