如标题,获取文件的MD5值,代码如下:
QFile file(image_path); //image_path为文件路径
QByteArray fileArray;
if (!file.open(QIODevice::ReadOnly))
{
//打开失败
return -1;
}
fileArray = file.readAll();
file.close();
QByteArray md5 = QCryptographicHash::hash(fileArray, QCryptographicHash::Md5); //获取结果是乱码
QString strMd5 = md5.toHex(); //转一下就行了