我正在用qt c++制作注册/登录表单在mysql中保存注册信息密码是用md5散列的,我也尝试过sha256,所以主要的问题是它保存散列的密码,我对此没有问题,但是当我在登录窗口中比较它时,它没有比较,出现密码错误的消息。没有散列,一切正常,有散列检查问题。谢谢你的帮助
if (db.open()) {
QString email = ui->email->text();
QString password = QString("%1").arg(QString(QCryptographicHash::hash(ui->password->text().toUtf8(),QCryptographicHash::Md5).toHex()));
// Insert Query
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");
ui->plstryagain->close();
db.close();
} else {
QMessageBox::information(this,"Wrong","Wrong Password try again");
ui->plstryagain->show();
db.close();
}
}
}
else {
QMessageBox::information(this, "Database Error", "Can't Connect To Database");
}
暂无答案!
目前还没有任何答案,快来回答吧!