Fatima IE
Fatima IE

Reputation: 47

How to recover your password forgotten if password hash by MD5

i made 2 program client and server and enter secure number if user forgotten password recover it by enter secure number it work correctly but if hash password by MD5 can not able to recover password by secure number i enter it and below is code about it

 ' query database, check if username and password are correct
    Dim mysqlDB As New mysql
    Dim userDB As String = mysqlDB.prepareQuery(arr(0).ToString)
    Dim passDB As String = mysqlDB.prepareQuery(arr(1).ToString)
    Dim query As String = "select * from users where userName='" + userDB + "' and password = '" + passDB + "'"
    mysqlDB.QueryDB(query)
    Dim found As Boolean = False

    ' read results
    While mysqlDB.reader.Read()
        username = mysqlDB.reader.GetString(1)
        password = mysqlDB.reader.GetString(2)
        clientPublicKey = mysqlDB.reader.GetString(3)
        found = True
    End While
    mysqlDB.CloseDB()

    If found = False Then   ' if not found check SecID

        query = "select password from users where userName='" + userDB + "' and SecID = '" + passDB + "'"
        mysqlDB.QueryDB(query)
        found = False
        ' read results
        While mysqlDB.reader.Read()
            password = "Your Password: " & mysqlDB.reader.GetString(0)
            Sbytes = Encoding.ASCII.GetBytes(password)
            found = True
        End While
        mysqlDB.CloseDB()
        If found = False Then   ' if not found send error message
            Sbytes = Encoding.ASCII.GetBytes("Wrong username or password")
        End If

        stream.Write(Sbytes, 0, Sbytes.Length)
        stream.Close()
        tcpClient.Close()
        Exit Sub

    End If
    ' close DB connection
    mysqlDB.CloseDB()

Upvotes: 0

Views: 120

Answers (1)

Niklaus
Niklaus

Reputation: 991

If you're asking if you could revert MD5 hash back to original password the answer is: "No, you cannot do that".

Upvotes: 1

Related Questions