Private Function getFileMd5Hash(ByVal filePath As String) As String
'创建MD5实例
Dim md5Hasher As MD5 = MD5.Create()
Dim strMD5 As String = String.Empty
'以字节形式读取文件
Dim originalDate As Byte() = My.Computer.FileSystem.ReadAllBytes(filePath)
'计算MD5
Dim data As Byte() = md5Hasher.ComputeHash(originalDate)
'创建可变字符串
Dim sBuilder As New StringBuilder()
' 连接每一个 byte 的 hash 码,并格式化为十六进制字符串
Dim i As Integer
For i = 0 To data.Length - 1
sBuilder.Append(data(i).ToString("x2"))
Next i
strMD5 = sBuilder.ToString
'md5Hasher.Dispose()
md5Hasher = Nothing
sBuilder = Nothing
originalDate = Nothing
data = Nothing
Return strMD5
End Function