QPasswordDigestor Namespace

QPasswordDigestor 名前空間には、ハッシュやキーの生成に使用できる関数が含まれています。詳細...

ヘッダ #include <QPasswordDigestor>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
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)

詳しい説明

関数のドキュメント

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

RFC 8018のセクション5.1で定義されているPBKDF1アルゴリズムを使って計算したハッシュを返す。

この関数は、datasalt を受け取り、指定されたハッシュalgorithm を使用してiterations を繰り返しハッシュする。結果のハッシュがdkLen より長い場合は、切り捨てられた後に返される。

この関数はSHA-1とMD5のみをサポートしている!最大出力サイズは、SHA-1の場合は160ビット(20バイト)、MD5の場合は128ビット(16バイト)である。これを超える値をdkLen に指定すると警告が表示され、空のQByteArray が返される。この制限をプログラムでチェックするには、QCryptographicHash::hashLength を使用することができる。さらに:salt は常に8バイト長でなければならない!

注: この関数はレガシー・アプリケーションで使用するために提供されており、新しいアプリケーショ ンはすべてPBKDF2 を使用することを推奨します。

deriveKeyPbkdf2QCryptographicHashQCryptographicHash::hashLengthも参照して ください。

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

RFC 8018の5.2節で定義されているPBKDF2-アルゴリズムを使用して鍵を導出する。

この関数はdatasalt を受け取り、HMAC-X(Xはalgorithm)を繰り返し適用する。この関数は内部的に、少なくともdkLen のバイト数が計算されるまで、中間結果を最終出力に連結し、連結が必要になるたびに HMAC-Xiterations を実行する。HMAC-Xを実行する合計回数は、iterationsdkLenalgorithm に依存し、iterations * ceil(dkLen / QCryptographicHash::hashLength(algorithm)) として計算できる。

deriveKeyPbkdf1QMessageAuthenticationCodeQCryptographicHashも参照のこと

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.