QString GetKeyPath::GetFileMd5(QString FilePath)
{//获取文件的md5
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec *code=QTextCodec::codecForName("utf8");//本人采用的是UTF8格式显示的
QFile file(FilePath);
QString macmd5 = "";
if(file.exists(FilePath))
{
file.open(QIODevice::ReadOnly);
QTextStream stream(&file);
stream.setCodec(code);//输出流的设置
QString txt="";
txt=stream.readAll();
QByteArray byte;
byte = txt.toAscii();
macmd5=QCryptographicHash::hash(byte,QCryptographicHash::Md5).toHex().constData();
}
return macmd5;
}
获取文件的md5
最新推荐文章于 2024-04-17 13:26:41 发布