Reputation: 21
I have this code below which coverts my textbox text to a variable characters and numbers. example: if i type "admin" to textbox1, i will have an output of "751cb3f4aa17c36186f4856c8982bf27". Now, I wanted to do the reverse. Anyone have any idea?
Dim hs As Byte() = New Byte(49) {}
Dim pass As String = textbox1.Text
Dim md5 As MD5 = MD5.Create()
Dim inputBytes As Byte() = Encoding.ASCII.GetBytes(pass)
Dim hash As Byte() = md5.ComputeHash(inputBytes)
Dim sb As StringBuilder = New StringBuilder()
For i As Integer = 0 To hash.Length - 1
hs(i) = hash(i)
sb.Append(hs(i).ToString("x2"))
Next
Dim hash_pass = sb.ToString()
Upvotes: 1
Views: 324
Reputation: 1218
You shouldn't be "reversing" an MD5 Hash. Hashes are meant to be one way only. If you want to be able to reverse the encoded message, you will want to use a cipher such as base64. It is worth noting, ciphers do not give you security as they can be restored to the original input.
This answer helps explain the differences and their different use cases.
Here is some documentation on using System.Convert.ToBase64String()
which can be reversed with System.Convert.FromBase64String()
Upvotes: 1