当前位置:网站首页>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个重要知识点:排序检索数据

Go从入门到实战——接口(笔记)

List of language weaknesses --cwe, a website worth learning

Go从入门到实战——channel的关闭和广播(笔记)

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

MYSQL和MongoDB的分析

How to delete "know this picture" on win11 desktop

AI painting minimalist tutorial

Go从入门到实战——仅执行一次(笔记)

Educational Codeforces Round 108 (Rated for Div. 2)
随机推荐
[LeetCode]515. Find the maximum value in each tree row
Sharing | intelligent environmental protection - ecological civilization informatization solution (PDF attached)
Method of reading file contents by Excel
Process control task
Quick excel export
matlab查找某一行或者某一列在矩阵中的位置
石子合并问题分析
100 important knowledge points that SQL must master: retrieving data
Go 访问GBase 8a 数据库的一个方法
Simulink导出FMU模型文件方法
Oracle migration MySQL unique index case insensitive don't be afraid
Go从入门到实战——仅需任意任务完成(笔记)
Go从入门到实战——Context与任务取消(笔记)
Little known MySQL import data
Tiktok's interest in e-commerce has hit the traffic ceiling?
Is it safe to open an account and buy stocks? Who knows
GBase 8a OLAP分析函数cume_dist的使用样例
AI painting minimalist tutorial
本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献
Set code exercise