QT中生成字符串md5的方法

Posted PhiliAI

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了QT中生成字符串md5的方法相关的知识,希望对你有一定的参考价值。

QT提供了QCryptographicHash类,想转md5或者sda1都很方便

QString fileText = original_Image.text();
QString fileCut = fileText.remove(256,fileText.count() - 256);
fileCut += QTime::currentTime().toString();//加上时间戳再生成
    
QByteArray ba;
ba =QCryptographicHash::hash(fileCut.toUtf8(),QCryptographicHash::Md5);
QString tempFilenamemd5(ba.toHex());

比如我要生成随机文件名字,可以加上时间戳什么的,比如上面的写法。

以上是关于QT中生成字符串md5的方法的主要内容,如果未能解决你的问题,请参考以下文章