我想计算RichTextBox1.Text
的MD5哈希值。我在顶部添加了这行代码,以便我可以使用MD5加密方法:Imports System.Security.Cryptography
。我如何实际计算哈希?
答案 0 :(得分:0)
该过程描述为here。
链接的基本代码是:
Dim Bytes() As Byte
Dim sb As New StringBuilder()
Bytes = Encoding.Default.GetBytes(RichTextBox1.Text)
'Get md5 hash
Bytes = MD5.Create().ComputeHash(Bytes)
'Loop though the byte array and convert each byte to hex.
For x As Integer = 0 To Bytes.Length - 1
sb.Append(Bytes(x).ToString("x2"))
Next
'Return md5 hash.
Return sb.ToString()