We have an old MySQL database that has passwords stored using the MySQL function PASSWORD(). Is there a way using Entity Framework in C# to select the row with the password?
The old way would be to do a sql query
SELECT * FROM `employees` WHERE `id` = @id AND `password` = PASSWORD(@pword);
The @id and @pword are then passed to the .Net Connector as parameters.
In Entity we do this
var query = from employeeRow in context.employees
where employeeRow.id.Equals(username_txt.Text)
select employeeRow;
_foundEmployee = query.SingleOrDefault();
But this will return the row data without checking the password. How would I check the password that has been hashed with MySQL PASSWORD()?
where employeeRow.id.Equals(username_txt.Text) && employeeRow.password.Equals(hashedPassword)
You need to do password hashing separately. I'd suspect mysql documentation will tell you what algorithm PASSWORD() method uses.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.