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
本文介绍了一种使用MD5算法进行字符串加密的方法。通过Visual Basic语言实现了一个公共函数,该函数接受输入字符串并返回经过MD5加密后的结果。具体步骤包括将字符串转换为字节数组、使用MD5算法计算哈希值以及将结果转换为32位的十六进制形式。
6914

被折叠的 条评论
为什么被折叠?



