Unable to generate MD5 of a QString
I am facing problem in generating an MD5 of a QString
QString hash_me = QString(QCryptographicHash::hash((png_links),QCryptographicHash::Md5).toHex()); png_links = hash_me ;
error that i am getting is :
error: no matching function for call to 'QCryptographicHash::hash(QString&, QCryptographicHash::Algorithm)' QString hash_me = QString(QCryptographicHash::hash((png_links),QCryptographicHash::Md5).toHex()); ^
QCryptographicHash::hash()method doesn't operate on
QString, it operates on
QByteArray QCryptographicHash::hash(const QByteArray &data, Algorithm method)
Therefore, you have to convert your
QStringclass provides several methods for that such as:
QByteArray QString::toLatin1() const
QByteArray QString::toLocal8Bit() const
QByteArray QString::toUtf8() const
As the method names indicate you will loose portability. You have to know which encoding you want to use.
Thanks !! I just figured it out after reading Docs !!
Thanks for replying (y)