1

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()
2
  • Hashes, such as md5 which you are using are one way hashes, their purpose is when a password is entered by the user, it can be hashed and then the hash can be compared against the one in the database to validate the password. This means if a hacker accesses your database they cannot get any passwords from it. Commented Apr 13, 2020 at 9:33
  • thankz for the abrupt answer. At least now i know what to do. Commented Apr 13, 2020 at 9:53

1 Answer 1

1

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()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.