我制作了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()
答案 0 :(得分:1)
如果您问是否可以将MD5哈希恢复为原始密码,答案是:“不,您不能这样做。”