码迷,mamicode.com
首页 > 其他好文 > 详细

Qt文件生成Md5

时间:2015-08-29 15:11:21      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

static bool GetFileMd5Code(const QString strFilePath, QString &strMD5Code)
{
    bool bRet = false;
    strMD5Code = "";

    if (!QFile::exists(strFilePath))
    {
        qDebug() << strFilePath << " don‘t exist!";
        return bRet;
    }

    QFile file(strFilePath);
    if (file.open(QIODevice::ReadOnly))
    {
        QCryptographicHash cryptographicHash(QCryptographicHash::Md5);
        cryptographicHash.addData(&file);
        strMD5Code = QString::fromLatin1(cryptographicHash.result().toHex());
        file.close();
        bRet = true;
    }

    qDebug() << "md5:" << strMD5Code;
    return bRet;
}

qDebug() << "md5:" << strMD5Code;
return bRet;
}

Qt文件生成Md5

标签:

原文地址:http://www.cnblogs.com/sz-leez/p/4769052.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!