Qt封装了下面的摘要算法,调用起来杠杠的。
从上面的表中可以得知,估计以后Keccak要变成主流的摘要算法了。
这个类提供了个静态函数,直接调用就可以了。
代码如下;
#include <QCoreApplication>
#include <QCryptographicHash>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex();
qDebug() << QCryptographicHash::hash("Hello World", QCryptographicHash::Sha256).toHex();
return a.exec();
}
运行截图如下: