#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
#include <QString>
#include <QCryptographicHash>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
QString pwd="alibaba";
QString md5;
QByteArray ba,bb;
QCryptographicHash md(QCryptographicHash::Md5);
ba.append(pwd);
md.addData(ba);
bb=md.result();
md5.append(bb.toHex());
qDebug()<<md5;
return a.exec();
}
本文展示了一个使用C++和Qt库进行字符串MD5加密的例子。通过QCryptographicHash类,将alibaba字符串转换为MD5哈希值,并在控制台输出十六进制表示的哈希结果。
1650

被折叠的 条评论
为什么被折叠?



