QPasswordDigestor 名称空间

QPasswordDigestor 名称空间包含可以用于生成哈希或键的函数。 更多...

头: #include <QPasswordDigestor>
CMake: find_package(Qt6 COMPONENTS Network REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

函数

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

详细描述

函数文档编制

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

返回计算哈希使用 PBKDF1 算法作为定义在 RFC 8018, section 5.1 .

函数接受 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!

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

该函数在 Qt 5.12 引入。

另请参阅 deriveKeyPbkdf2 , QCryptographicHash ,和 QCryptographicHash::hashLength .

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

派生密钥使用 PBKDF2 算法作为定义在 RFC 8018, section 5.2 .

此函数接受 data and salt ,然后应用 HMAC-X,其中 X 是 algorithm , repeatedly. It internally concatenates intermediate results to the final output until at least dkLen amount of bytes have been computed and it will execute HMAC-X iterations times each time a concatenation is required. The total number of times it will execute HMAC-X depends on iterations , dkLen and algorithm and can be calculated as iterations * ceil(dkLen / QCryptographicHash::hashLength(algorithm)) .

该函数在 Qt 5.12 引入。

另请参阅 deriveKeyPbkdf1 , QMessageAuthenticationCode ,和 QCryptographicHash .