VB.NET里的MD5加密函数

Imports System.Security.Cryptography

Public Function Md5hash_String(ByVal InputString As String) As String
Dim code, MD5
Dim dataToHash As Byte() = (New System.Text.ASCIIEncoding).GetBytes(InputString)
Dim hashvalue As Byte() = CType(System.Security.Cryptography.CryptoConfig.CreateFromName("MD5"), System.Security.Cryptography.HashAlgorithm).ComputeHash(dataToHash)
Dim i As Integer
For i = 0 To 15 '选择32位字符的加密结果
MD5 += Hex(hashvalue(i)).ToLower
Next
Return MD5
End Function

你可能感兴趣的:(.net,Security,vb,VB.NET)