当前位置:网站首页>QT large file generation MD5 check code
QT large file generation MD5 check code
2022-06-27 21:52:00 【Oriental forgetfulness】
Common types
enumeration QCryptographicHash::Algorithm:
QCryptographicHash::Md4 0 Generate a MD4 hash
QCryptographicHash::Md5 1 Generate a MD5 hash
QCryptographicHash::Sha1 2 Generate a SHA-1 hash
QCryptographicHash::Sha224 3 Generate a SHA-224 hash (SHA-2)
QCryptographicHash::Sha256 4 Generate a SHA-256 hash (SHA-2)
QCryptographicHash::Sha384 5 Generate a SHA-384 hash (SHA-2)
QCryptographicHash::Sha512 6 Generate a SHA-512 hash (SHA-2)
QCryptographicHash::Sha3_224 7 Generate a SHA3-224 hash
QCryptographicHash::Sha3_256 8 Generate a SHA3-256 hash
QCryptographicHash::Sha3_384 9 Generate a SHA3-384 hash
QCryptographicHash::Sha3_512 10 Generate a SHA3-512 hash
QString MakeMd5(const QString &sourceFilePath)
{
QFile sourceFile(sourceFilePath);
qint64 fileSize = sourceFile.size();
const qint64 bufferSize = 1024*10;
if (sourceFile.open(QIODevice::ReadOnly)) {
char buffer[bufferSize];
int bytesRead;
int readSize = qMin(fileSize, bufferSize);
QCryptographicHash hash(QCryptographicHash::Md5);
while (readSize > 0 && (bytesRead = sourceFile.read(buffer, readSize)) > 0) {
fileSize -= bytesRead;
hash.addData(buffer, bytesRead);
readSize = qMin(fileSize, bufferSize);
}
sourceFile.close();
return QString(hash.result().toHex());
}
return QString();
}
边栏推荐
- SQL必需掌握的100个重要知识点:过滤数据
- Codeforces Round #716 (Div. 2)
- Interval DP of Changyou dynamic programming
- STM32F107+LAN8720A使用STM32cubeMX配置网络连接+tcp主从机+UDP app
- 石子合并问题分析
- 创建对象时JVM内存结构
- Go从入门到实战——接口(笔记)
- Go从入门到实战——任务的取消(笔记)
- Go from introduction to practice -- coordination mechanism (note)
- Go from introduction to actual combat -- channel closing and broadcasting (notes)
猜你喜欢

Tiktok's interest in e-commerce has hit the traffic ceiling?

SQL必需掌握的100个重要知识点:使用函数处理数据

Go from introduction to practice - Interface (notes)

Burp suite遇到的常见问题

C语言程序设计详细版 (学习笔记1) 看完不懂,我也没办法。

Interval DP of Changyou dynamic programming

Go from introduction to actual combat - panic and recover (notes)

Go从入门到实战——Panic和recover(笔记)

01-Golang-环境搭建

Go从入门到实战—— 多路选择和超时控制(笔记)
随机推荐
Go from introduction to actual combat - package (notes)
微服务之远程调用
[LeetCode]30. Concatenate substrings of all words
[Sword Offer II]剑指 Offer II 029. 排序的循环链表
[LeetCode]508. 出現次數最多的子樹元素和
我想我要开始写我自己的博客了。
[LeetCode]100. 相同的树
Go從入門到實戰——接口(筆記)
Go从入门到实战——Context与任务取消(笔记)
GBase 8a OLAP分析函数 cume_dist的使用样例
[LeetCode]515. 在每个树行中找最大值
Knowledge sorting of exception handling
Go从入门到实战——channel的关闭和广播(笔记)
Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear
Acwing周赛57-数字操作-(思维+分解质因数)
Go from entry to practice -- CSP concurrency mechanism (note)
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
神奇的POI读取excel模板文件报错
JVM memory structure when creating objects
Special training of guessing game