I want to calculate the MD5 Hash of RichTextBox1.Text
. I've added this line of code at the top so that I can use the MD5 encryption method: Imports System.Security.Cryptography
. How do I go about actually calculating the hash?
Asked
Active
Viewed 6,229 times
-3
-
1MD5 is no encryption. – Uwe Keim May 31 '15 at 16:53
-
I remember watching a video where they used `System.Security.Cryptography` to encrypt text into an md5 hash. – DomMC PvP May 31 '15 at 16:54
-
2[MD5 Class](https://msdn.microsoft.com/en-us/library/system.security.cryptography.md5(v=vs.110).aspx) – Ňɏssa Pøngjǣrdenlarp May 31 '15 at 16:55
-
Note: The video was very bad quality. The only thing that stood out clearly was the class name and the namespace. – DomMC PvP May 31 '15 at 16:55
-
That's for console... Not VB.NET. – DomMC PvP May 31 '15 at 16:56
1 Answers
0
The process is described here.
The basic code from the link is:
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()

Cu3PO42
- 1,403
- 1
- 11
- 19