当前位置:网站首页>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();
}
边栏推荐
- 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!"
- 石子合并问题分析
- 微服务之远程调用
- 我想我要开始写我自己的博客了。
- Go从入门到实战——仅需任意任务完成(笔记)
- 创建对象时JVM内存结构
- 动态刷新mapper看过来
- GBase 8a OLAP分析函数cume_dist的使用样例
- Go从入门到实战——CSP并发机制(笔记)
- [leetcode] dynamic programming solution split integer i[silver fox]
猜你喜欢

Go从入门到实战——行为的定义和实现(笔记)

创建对象时JVM内存结构

Go from entry to practice -- CSP concurrency mechanism (note)

Set code exercise

Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear

微服务之远程调用

Educational Codeforces Round 108 (Rated for Div. 2)

Go from introduction to practice - Interface (notes)

∫(0→1) ln(1+x) / (x² + 1) dx

Codeforces Round #716 (Div. 2)
随机推荐
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!"
Codeforces Global Round 14
TreeSet详解
[LeetCode]30. Concatenate substrings of all words
[LeetCode]572. 另一棵树的子树
Codeforces Round #722 (Div. 2)
Installing Oracle11g under Linux
鲜为人知的mysql导入数据
Go 访问GBase 8a 数据库的一个方法
Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer
matlab查找某一行或者某一列在矩阵中的位置
数组作业题
Special training of guessing game
[LeetCode]100. Same tree
Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
The difference between scrum and Kanban
Go從入門到實戰——接口(筆記)
Acwing周赛57-最长连续子序列-(二分or树状数组)
Null pointer exception
Go从入门到实战——仅需任意任务完成(笔记)