qt mysql database md5 password cheking problem





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am making registration/login form with qt c++ saving registration information in mysql password is hashed by md5 also I've tried sha256 same there, so main problem it saves password hashed and I've got no problem with that but when i'm comparing it in login window it doesn't compares and password wrong message appears. without hashing everything works fine, with hashing checking problem. Thanks for help))



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");
}









share|improve this question




















  • 1





    How do you store the password on creation ?

    – Pratham
    Nov 16 '18 at 17:27






  • 1





    Well, have you debugged your code to see what it is comparing?

    – user1531971
    Nov 16 '18 at 17:41


















0















I am making registration/login form with qt c++ saving registration information in mysql password is hashed by md5 also I've tried sha256 same there, so main problem it saves password hashed and I've got no problem with that but when i'm comparing it in login window it doesn't compares and password wrong message appears. without hashing everything works fine, with hashing checking problem. Thanks for help))



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");
}









share|improve this question




















  • 1





    How do you store the password on creation ?

    – Pratham
    Nov 16 '18 at 17:27






  • 1





    Well, have you debugged your code to see what it is comparing?

    – user1531971
    Nov 16 '18 at 17:41














0












0








0








I am making registration/login form with qt c++ saving registration information in mysql password is hashed by md5 also I've tried sha256 same there, so main problem it saves password hashed and I've got no problem with that but when i'm comparing it in login window it doesn't compares and password wrong message appears. without hashing everything works fine, with hashing checking problem. Thanks for help))



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");
}









share|improve this question
















I am making registration/login form with qt c++ saving registration information in mysql password is hashed by md5 also I've tried sha256 same there, so main problem it saves password hashed and I've got no problem with that but when i'm comparing it in login window it doesn't compares and password wrong message appears. without hashing everything works fine, with hashing checking problem. Thanks for help))



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");
}






c++ mysql qt md5 sha256






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 19:29









pushkin

4,726113055




4,726113055










asked Nov 16 '18 at 15:58









Elen RiannonElen Riannon

1




1








  • 1





    How do you store the password on creation ?

    – Pratham
    Nov 16 '18 at 17:27






  • 1





    Well, have you debugged your code to see what it is comparing?

    – user1531971
    Nov 16 '18 at 17:41














  • 1





    How do you store the password on creation ?

    – Pratham
    Nov 16 '18 at 17:27






  • 1





    Well, have you debugged your code to see what it is comparing?

    – user1531971
    Nov 16 '18 at 17:41








1




1





How do you store the password on creation ?

– Pratham
Nov 16 '18 at 17:27





How do you store the password on creation ?

– Pratham
Nov 16 '18 at 17:27




1




1





Well, have you debugged your code to see what it is comparing?

– user1531971
Nov 16 '18 at 17:41





Well, have you debugged your code to see what it is comparing?

– user1531971
Nov 16 '18 at 17:41












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341401%2fqt-mysql-database-md5-password-cheking-problem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341401%2fqt-mysql-database-md5-password-cheking-problem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues