So, I have a login and I'm using Linq, C#, to check if there is a pair username/password that fits the user input. If there is any, it is stored in a User variable. If user==null
, the login fails, if the user!=null
, success! Now, I encrypted my pass and I need to redo the login code so I can compare the user input and the hashed pass stored on the database. I'm using this class to hash:
https://stackoverflow.com/a/32191537/1695100
My login code
private void button_LogInEntrar_Click(object sender, EventArgs e)
{
string username = tb_LogInUsername.Text;
string password = tb_LogInPass.Text;
User userAdmin = (from admin in dbATMT.UserSet.OfType<Administrator>()
where admin.Username.Equals(username) && admin.Password.Equals(password)
select admin).FirstOrDefault();
if (userAdmin == null)
{
MessageBox.Show("Invalid");
}
else
{
//logs in
}
}