QPasswordDigestor 命名空间

The QPasswordDigestor namespace contains functions which you can use to generate hashes or keys. 更多...

头文件 #include <QPasswordDigestor>
CMakefind_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmakeQT += network

函数

QByteArrayderiveKeyPbkdf1(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)
QByteArrayderiveKeyPbkdf2(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)

详细描述

函数文档

QByteArray QPasswordDigestor::deriveKeyPbkdf1(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)

Returns a hash computed using the PBKDF1-algorithm as defined in RFC 8018, section 5.1.

The function takes the data and salt, and then hashes it repeatedly for iterations iterations using the specified hash algorithm. If the resulting hash is longer than dkLen then it is truncated before it is returned.

This function only supports SHA-1 and MD5! The max output size is 160 bits (20 bytes) when using SHA-1, or 128 bits (16 bytes) when using MD5. Specifying a value for dkLen which is greater than this results in a warning and an empty QByteArray is returned. To programmatically check this limit you can use QCryptographicHash::hashLength. Furthermore: the salt must always be 8 bytes long!

Note: This function is provided for use with legacy applications and all new applications are recommended to use PBKDF2.

See also deriveKeyPbkdf2, QCryptographicHash, and QCryptographicHash::hashLength.

QByteArray QPasswordDigestor::deriveKeyPbkdf2(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)

Derive a key using the PBKDF2-algorithm as defined in RFC 8018, section 5.2.

此函数接收数据盐值,然后反复应用HMAC-X算法,其中X为算法。函数内部将中间结果连接到最终输出,直到计算出的字节至少达到dkLen量为止。当需要连接时,它将执行HMAC-X的迭代次数。HMAC-X执行的总次数取决于迭代次数dkLen算法,可计算为iterations * ceil(dkLen / QCryptographicHash::hashLength(algorithm))

也见deriveKeyPbkdf1QMessageAuthenticationCodeQCryptographicHash

© 2024 Qt公司。本文档的贡献者保留各自的版权。此处提供的文档是在自由软件基金会发布并在GNU自由文档许可协议版本1.3条款下提供的。Qt及其相关标志是芬兰及/或其他国家的Qt公司的商标。所有其他商标均为其各自所有者的财产。