I want to create a MD5 hash code in Qt.
My code :
QString queryStr;
queryStr = QString("%1")
.arg(QString(QCryptographicHash::hash(ui->txtPassword->text(),QCryptographicHash::Md5).toHex()));
but my code does not work!
hash
method does not work in Qt!
Any suggestion?
I used of
toStdString().c_str()
to casting fromQString
toconst char*
instatic QByteArray hash(const QByteArray &data, Algorithm method);
method as bellow :text()
returnsQString
,QCryptographicHash::hash
requiresQByteArray
and there is no implicit conversion, so you should do this by yourself. Use something like this:In the documentation you can see another mrthods which returns
QByteArray
. Choose the best for you.http://qt-project.org/doc/qt-5/qstring.html