Hi!
First of all, you need to now that I'm not very fluent in English, then be lenient if some of my explanation are not very good.
I'm trying to create some sort of authentication software on my stage, we give a pair username / pwd then the software must check whether the username exists in the database then check if pwd matches.
But I stumble on two problems :
- The first : the pwd stored in the SQL database are hashed (and maybe salty), and I wonder if with Qt, it could be hashed and salted in the same way so that both pwd correspond to history compare, if so, how?
- The second : I don't know what to request and what order to perform the above steps, I would like to know if you could also help me on this point (possibly with specific code).
Here is my actual code ( these are just attempts ):
void loginFen::buttonConnect_onClicked()
{
query.prepare("SELECT mdp from users WHERE pseudo=:pseudo");
query.bindValue(":pseudo", pseudo->text());
if(query.exec())
{
//query.first();
if(query.value(2).toString() == password->text()) // the problem is here
{
close();
Fenetre *Fen = new Fenetre;
Fen->show();
Fen->loadStyle();
}
else
{
QMessageBox::information(this,
"Erreur de saisie",
"Le mot de passe que vous avez entré est incorrect, veuillez réessayer");
// wrong password }
}
else
{
QMessageBox::information(this,
"Erreur de saisie",
"Le pseudo que vous avez entré est incorrect, veuillez réessayer"); wrong pseudo
}
void loginFen::buttonConnect_onClicked()
{
QSqlQuery query;
query.prepare("SELECT mdp from users WHERE pseudo=:pseudo");
query.bindValue(":pseudo", pseudo->text());
if(query.exec())
{
//query.first();
if(query.value(2).toString() == password->text()) // the problem is here
{
close();
Fenetre *Fen = new Fenetre;
Fen->show();
Fen->loadStyle();
}
else
{
QMessageBox::information(this, "Erreur de saisie", "Le mot de passe que vous avez entré est incorrect, veuillez réessayer"); // wrong password
}
}
else
{
QMessageBox::information(this, "Erreur de saisie", "Le pseudo que vous avez entré est incorrect, veuillez réessayer"); wrong pseudo
}
To copy to clipboard, switch view to plain text mode
Thanks for your help anyway & thank you to tell me if it is not accurate enough, in which case, I'll explain again my problem !
Bookmarks