使用Qt中提供的QCryptographicHash类,引入头文件#include <QCryptographicHash>,可以QCryptographicHash类比较简单

方法1:

 1 QString GetMd5(const QString& value) {
 2         QString md5;
 3         QByteArray ba, md_result;
 4         QCryptographicHash md(QCryptographicHash::Md5);
 5         ba.append(value);
 6         md.addData(ba);
 7         md_result = md.result();
 8         md5.append(md_result.toHex());
 9 
10         return md5;
11     }

方法2:

1 QString GetMd5(const QString& value) {
2         QString md5;
3         QByteArray bb;
4         bb = QCryptographicHash::hash(value.toUtf8(), QCryptographicHash::Md5);
5         md5.append(bb.toHex());
6 
7         return md5;
8     }

 

相关文章:

  • 2021-10-05
  • 2022-12-23
  • 2021-06-12
猜你喜欢
  • 2022-01-27
  • 2021-12-31
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案