qt 之加密篇 md5
阿新 • • 發佈:2019-02-16
#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);
QStringmd5;
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();
}