Ich habe eine Homepage mit einem Login mit $ hash = password_hash ($ accountpassword, PASSWORD_DEFAULT) ;. mySQl Login mit C#
Das Passwort wird als Hash gespeichert, der mit $ 2y $ beginnt.
Dann habe ich den Login in C#:
//crypting the PW that user enter
string cryptedPassword = Crypter.Blowfish.Crypt(textBox_password.Text);
string user = textBox_username.Text;
string pass = cryptedPassword;
if (user == "" || pass == "")
{
MessageBox.Show("Empty Fields Detected ! Please fill up all the fields");
return;
}
bool r = validate_login(user, pass);
if (r)
MessageBox.Show("Correct Login Credentials");
else
MessageBox.Show("Incorrect Login Credentials"+cryptedPassword);
meine Validate-Methode:
private bool validate_login(string user, string pass)
{
db_connection();
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "Select * from users where [email protected] and [email protected]";
cmd.Parameters.AddWithValue("@user", user);
cmd.Parameters.AddWithValue("@pass", pass);
cmd.Connection = connect;
MySqlDataReader login = cmd.ExecuteReader();
if (login.Read())
{
connect.Close();
return true;
}
else
{
connect.Close();
return false;
}
}
bei Crypter.Blowfish.Crypt (textBox_password.Text) ist worng. Ich werde ein Hash beginnt mit $ 2a $
kann jemand helfen, dieses Problem zu beheben?
hmm das PHP-Skript ist nicht meine Arbeit. Wie kann ich den 2. Parameter herausfinden? – Andreas
Verwenden Sie etwas wie 'Crypter.Blowfish.GenerateSalt (6)' und speichern Sie diesen Wert, oder verwenden Sie eine Zeichenfolge Ihrer Wahl (weniger sicher). Ich habe meine Antwort aktualisiert, um eine alternative Methode hinzuzufügen, die es Ihnen ermöglichen sollte, die Überprüfung durchzuführen, ohne das Salz zu lagern. – Graeme