当前位置:网站首页>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();
}
边栏推荐
- Special training of guessing game
- Go从入门到实战——协程机制(笔记)
- 动态刷新mapper看过来
- Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear
- Go 访问GBase 8a 数据库的一个方法
- 100 important knowledge points that SQL must master: retrieving data
- [LeetCode]100. 相同的树
- Knowledge sorting of exception handling
- SQL必需掌握的100个重要知识点:检索数据
- io流代码
猜你喜欢

Go from starting to Real - Interface (note)

Go从入门到实战——共享内存并发机制(笔记)

Process control task

Express e stack - small items in array

Go from introduction to actual combat - context and task cancellation (notes)

01-Golang-环境搭建

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

Codeforces Global Round 14

Go从入门到实战——协程机制(笔记)
![[leetcode] dynamic programming solution split integer i[silver fox]](/img/18/8dc8159037ec1262444db8899cde0c.png)
[leetcode] dynamic programming solution split integer i[silver fox]
随机推荐
Go从入门到实战——package(笔记)
After being forced to develop the app within 20 days, the group was laid off, and the technical director angrily criticized it: I wish "closure as soon as possible!"
IO stream code
Go从入门到实战——接口(笔记)
100 important knowledge points that SQL must master: combining where clauses
win11桌面出现“了解此图片”如何删除
CEPH distributed storage
MYSQL和MongoDB的分析
"Apprendre cette image" apparaît sur le Bureau win11 comment supprimer
qt 大文件生成md5校验码
GBase 8a OLAP分析函数cume_dist的使用样例
Go from starting to Real - Interface (note)
[LeetCode]30. 串联所有单词的子串
[Sword Offer II]剑指 Offer II 029. 排序的循环链表
开源技术交流丨一站式全自动化运维管家ChengYing入门介绍
Go from introduction to actual combat - panic and recover (notes)
Codeforces Round #721 (Div. 2)
SQL必需掌握的100个重要知识点:组合 WHERE 子句
Set code exercise
分享|智慧环保-生态文明信息化解决方案(附PDF)