Maybe I lost my intelligence, but I really do not why this code do not behave correctly.
bool loginDialog::check()
{
qDebug()<<"LD check"<<usernames<<passwords;
qDebug()<<"LD input"<<username<<password<<usernames.contains(username.trimmed());
if (usernames.contains(username.trimmed()))
{
p = passwords.at(usernames.indexOf(username));
qDebug()<<"LD password"
"input"<<p<<QCryptographicHash::hash(password.toLocal8Bit(),QCryptographicHash::Md5);
in = QCryptographicHash::hash(password.toLocal8Bit(),QCryptographicHash::Md5);
if ( in == p)
{
qDebug()<<"ACCEPTED"<< p.toLocal8Bit() << in;
return true;
}
else
{
qDebug()<<"NO ACCEPTED"<<in<<p;
return false;
SleeperThread::msleep(900);
}
}
return false;
}
bool loginDialog::check()
{
qDebug()<<"LD check"<<usernames<<passwords;
qDebug()<<"LD input"<<username<<password<<usernames.contains(username.trimmed());
QString p;
QByteArray in;
if (usernames.contains(username.trimmed()))
{
p = passwords.at(usernames.indexOf(username));
qDebug()<<"LD password"
"input"<<p<<QCryptographicHash::hash(password.toLocal8Bit(),QCryptographicHash::Md5);
in = QCryptographicHash::hash(password.toLocal8Bit(),QCryptographicHash::Md5);
if ( in == p)
{
qDebug()<<"ACCEPTED"<< p.toLocal8Bit() << in;
return true;
}
else
{
qDebug()<<"NO ACCEPTED"<<in<<p;
return false;
SleeperThread::msleep(900);
}
}
return false;
}
To copy to clipboard, switch view to plain text mode
The output at run is as follow
LD check ("administrator") ("!#/)zW¥§C?JJ?Ã")
LD input "administrator" "admin" true
LD passwordinput "!#/)zW¥§C?JJ?Ã" "!#/)zW¥§C?JJ?Ã"
NO ACCEPTED "!#/)zW¥§C?JJ?Ã" "!#/)zW¥§C?JJ?Ã"
LD check ("administrator") ("!#/)zW¥§C?JJ?Ã")
LD input "administrator" "admin" true
LD passwordinput "!#/)zW¥§C?JJ?Ã" "!#/)zW¥§C?JJ?Ã"
NO ACCEPTED "!#/)zW¥§C?JJ?Ã" "!#/)zW¥§C?JJ?Ã"
To copy to clipboard, switch view to plain text mode
As you can see the variables "in" and "p" have the same value, but the "if" lands always in the NO ACCEPTED state.
Regards
Bookmarks