1.
#include <QtCore/QCoreApplication> #include <QCryptographicHash>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString pwd="abcdef";
QString md5;
QByteArray ba,bb;
QCryptographicHash md(QCryptographicHash::Md5);
ba.append(pwd);
md.addData(ba);
bb = md.result();
md5.append(bb.toHex());
std::cout<<md5.toStdString()<<std::endl;
return a.exec();
}
2.
#include <QtCore/QCoreApplication> #include <QCryptographicHash>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString md5;
QString pwd="abcdef";
QByteArray bb;
bb = QCryptographicHash::hash(pwd.toAscii(),QCryptographicHash::Md5 );
md5.append(bb.toHex());
std::cout<<md5.toStdString()<<std::endl;
return a.exec();
}