QCryptographicHash

QCryptographicHash 

Header: #include <QCryptographicHash>
qmake: QT += core
Since: Qt 4.3

 

注意:在5.9之前的Qt版本中,当被要求生成SHA3时,qcryptographicshash实际上计算了Keccak。如果您需要与Qt版本生成的SHA-3哈希兼容,请使用Keccak_u枚举器。或者,如果需要源兼容性,则定义宏QT_uSha3\u KECCAK_uUcompat。

 

ConstantValueDescription
QCryptographicHash::Md4 0 Generate an MD4 hash sum
QCryptographicHash::Md5 1 Generate an MD5 hash sum
QCryptographicHash::Sha1 2 Generate an SHA-1 hash sum
QCryptographicHash::Sha224 3 Generate an SHA-224 hash sum (SHA-2). Introduced in Qt 5.0
QCryptographicHash::Sha256 4 Generate an SHA-256 hash sum (SHA-2). Introduced in Qt 5.0
QCryptographicHash::Sha384 5 Generate an SHA-384 hash sum (SHA-2). Introduced in Qt 5.0
QCryptographicHash::Sha512 6 Generate an SHA-512 hash sum (SHA-2). Introduced in Qt 5.0
QCryptographicHash::Sha3_224 RealSha3_224 Generate an SHA3-224 hash sum. Introduced in Qt 5.1
QCryptographicHash::Sha3_256 RealSha3_256 Generate an SHA3-256 hash sum. Introduced in Qt 5.1
QCryptographicHash::Sha3_384 RealSha3_384 Generate an SHA3-384 hash sum. Introduced in Qt 5.1
QCryptographicHash::Sha3_512 RealSha3_512 Generate an SHA3-512 hash sum. Introduced in Qt 5.1
QCryptographicHash::Keccak_224 7 Generate a Keccak-224 hash sum. Introduced in Qt 5.9.2
QCryptographicHash::Keccak_256 8 Generate a Keccak-256 hash sum. Introduced in Qt 5.9.2
QCryptographicHash::Keccak_384 9 Generate a Keccak-384 hash sum. Introduced in Qt 5.9.2
QCryptographicHash::Keccak_512 10 Generate a Keccak-512 hash sum. Introduced in Qt 5.9.2

 

 

 

复制代码
void MainWindow::getMd5(QString pwdStr)
{
    QString md5Str;
    QByteArray byteArray1, byteArray2;
    QCryptographicHash md(QCryptographicHash::Md5);
    byteArray1.append(pwdStr);
    md.addData(byteArray1);
    byteArray2 = md.result();
    md5Str.append(byteArray2.toHex());
    qDebug() << md5Str;

    return md5Str;    
}
复制代码

 

 

Md5:
a94db642b34e5f34d75c14c5aeeda36f


Keccak_512:
a95c153b9bd4b32910b08c7d591866d949df2aa3e3fb62ed423ea5fd72c3e4ca05b2f1baa8a01fba9054a797589660f0988e22654ad3b0a77eee391b8bf5686b

 

 

################

posted @   西北逍遥  阅读(477)  评论(6编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
历史上的今天:
2020-06-24 IfcBlock
2020-06-24 IfcCsgPrimitive3D
2019-06-24 osg MatrixManipulator CameraManipulator
2019-06-24 osg::MatrixTransform 模型基本变换
点击右上角即可分享
微信分享提示