Answer the question
In order to leave comments, you need to log in
Problem with checking hashed password (c++ mysql) how to fix?
I am doing a registration / login program on the qt framework, everything worked, except for checking the hashed password,
in mysql it is written normally hash md5 tried sha256 everything is fine during registration, and when I compare passwords it says that it is not correct, without hasha everything works even if copied from mysql a hashed password and enter also works, but if you rewrite it to check the hash, it's always an error.
if(db.open())
{
QString email = ui->email->text();
QString password = QString("%1").arg(
QString(QCryptographicHash::hash(ui->password->text().toUtf8(),
QCryptographicHash::Md5).toHex()));
QSqlQuery query(QSqlDatabase::database("MyConnection"));
query.prepare("SELECT * FROM users WHERE email = :email AND password = :password");
query.bindValue(":email", email);
query.bindValue(":password", password);
if(!query.exec())
{
QMessageBox::information(this,"Failed","Error please try again");
}
else
{
QString emailLog = query.value(1).toString();
QString passwordLog = query.value(4).toString();
if (query.next()) {
QMessageBox::information(this,"SUCCESS","SUCCESS");
db.close();
} else {
QMessageBox::information(this,"Wrong","Wrong Password try again");
db.close();
}
}
}
else
{
QMessageBox::information(this, "Database Error", "Can't Connect To Database");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question