-3

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?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
DomMC PvP
  • 1
  • 1
  • 2

1 Answers1

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