如果MD5密码哈希,如何恢复密码忘记



我制作了2个程序客户端和服务器,并输入安全号码,如果用户忘记的密码通过输入安全号码恢复它,则它可以正常工作,但是如果MD5的哈希密码无法通过安全号码恢复密码我输入它,以下是有关它的代码

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

如果您询问是否可以将MD5 Hash恢复为原始密码,答案是:"不,您不能做到这一点"。

相关内容

  • 没有找到相关文章

最新更新