QCryptographicHash Class

QCryptographicHash クラスは、暗号ハッシュを生成する方法を提供する。詳細...

ヘッダー #include <QCryptographicHash>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

注意:このクラスの関数はすべてリエントラントです。

パブリック型

enum Algorithm { Md4, Md5, Sha1, Sha224, Sha256, …, Blake2s_256 }

パブリック関数

QCryptographicHash(QCryptographicHash::Algorithm method)
(since 6.5) QCryptographicHash(QCryptographicHash &&other)
~QCryptographicHash()
void addData(QByteArrayView bytes)
bool addData(QIODevice *device)
(since 6.5) QCryptographicHash::Algorithm algorithm() const
void reset()
QByteArray result() const
(since 6.3) QByteArrayView resultView() const
(since 6.5) void swap(QCryptographicHash &other)
(since 6.5) QCryptographicHash &operator=(QCryptographicHash &&other)

静的パブリックメンバ

QByteArray hash(QByteArrayView data, QCryptographicHash::Algorithm method)
(since 6.8) QByteArrayView hashInto(QSpan<char> buffer, QByteArrayView data, QCryptographicHash::Algorithm method)
(since 6.8) QByteArrayView hashInto(QSpan<char> buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)
(since 6.8) QByteArrayView hashInto(QSpan<std::byte> buffer, QByteArrayView data, QCryptographicHash::Algorithm method)
(since 6.8) QByteArrayView hashInto(QSpan<std::byte> buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)
(since 6.8) QByteArrayView hashInto(QSpan<uchar> buffer, QByteArrayView data, QCryptographicHash::Algorithm method)
(since 6.8) QByteArrayView hashInto(QSpan<uchar> buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)
int hashLength(QCryptographicHash::Algorithm method)
(since 6.5) bool supportsAlgorithm(QCryptographicHash::Algorithm method)

詳しい説明

QCryptographicHash は、バイナリまたはテキストデータの暗号ハッシュを生成するために使用できます。

サポートされているアルゴリズムの一覧については、QCryptographicHash::Algorithm enum のドキュメントを参照してください。

メンバ型ドキュメント

enum QCryptographicHash::Algorithm

注意: Qt の 5.9 より前のバージョンでは、SHA3 ハッシュの合計を生成するように要求されると、QCryptographicHash は実際に Keccak を計算しました。これらのバージョンの Qt で生成された SHA-3 ハッシュとの互換性が必要な場合は、Keccak_ の列挙子を使用してください。また、ソースとの互換性が必要な場合は、マクロQT_SHA3_KECCAK_COMPAT を定義してください。

定数説明
QCryptographicHash::Md40MD4 ハッシュ和を生成します。
QCryptographicHash::Md51MD5 ハッシュ和を生成する
QCryptographicHash::Sha12SHA-1ハッシュ合計を生成する
QCryptographicHash::Sha2243SHA-224 ハッシュ和 (SHA-2) を生成します。Qt 5.0 で導入されました。
QCryptographicHash::Sha2564SHA-256 ハッシュ和 (SHA-2) を生成します。Qt 5.0 で導入。
QCryptographicHash::Sha3845SHA-384 ハッシュ和 (SHA-2) を生成します。Qt 5.0 で導入。
QCryptographicHash::Sha5126SHA-512 ハッシュ和 (SHA-2) を生成します。Qt 5.0 で導入。
QCryptographicHash::Sha3_224RealSha3_224SHA3-224 ハッシュ和を生成します。Qt 5.1 で導入。
QCryptographicHash::Sha3_256RealSha3_256SHA3-256 ハッシュ和を生成します。Qt 5.1 で導入。
QCryptographicHash::Sha3_384RealSha3_384SHA3-384 ハッシュ和を生成します。Qt 5.1 で導入。
QCryptographicHash::Sha3_512RealSha3_512SHA3-512 ハッシュ和を生成します。Qt 5.1 で導入。
QCryptographicHash::Keccak_2247Keccak-224 ハッシュ和を生成します。Qt 5.9.2 で導入。
QCryptographicHash::Keccak_2568Keccak-256 ハッシュ和を生成します。Qt 5.9.2 で導入。
QCryptographicHash::Keccak_3849Keccak-384 ハッシュ和を生成します。Qt 5.9.2 で導入。
QCryptographicHash::Keccak_51210Keccak-512 ハッシュ和を生成します。Qt 5.9.2 で導入。
QCryptographicHash::Blake2b_16015BLAKE2b-160 ハッシュ和を生成します。Qt 6.0 で導入。
QCryptographicHash::Blake2b_25616BLAKE2b-256 ハッシュ和を生成します。Qt 6.0 で導入。
QCryptographicHash::Blake2b_38417BLAKE2b-384 ハッシュ和を生成します。Qt 6.0 で導入。
QCryptographicHash::Blake2b_51218BLAKE2b-512 ハッシュ和を生成します。Qt 6.0 で導入。
QCryptographicHash::Blake2s_12819BLAKE2s-128 ハッシュ和を生成します。Qt 6.0 で導入。
QCryptographicHash::Blake2s_16020BLAKE2s-160 ハッシュ和を生成します。Qt 6.0 で導入。
QCryptographicHash::Blake2s_22421BLAKE2s-224 ハッシュ和を生成します。Qt 6.0 で導入。
QCryptographicHash::Blake2s_25622BLAKE2s-256 ハッシュ和を生成します。Qt 6.0 で導入。

メンバ関数のドキュメント

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<char> buffer, QByteArrayView data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<char> buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<std::byte> buffer, QByteArrayView data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<std::byte> buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<uchar> buffer, QByteArrayView data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<uchar> buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)

method を使ってdata のハッシュを返し、buffer を使って結果を格納する。

data がスパンである場合、指定された順序で、すべてのバイト配列ビューをハッシュに追加します。

戻り値は、buffer のサブスパンです。ただし、buffer のサイズが十分でない場合は、NULLQByteArrayView が返されます。

この関数は Qt 6.8 で導入されました。

hash()も参照してください

[explicit] QCryptographicHash::QCryptographicHash(QCryptographicHash::Algorithm method)

method を使ってデータから暗号ハッシュを作成するのに使えるオブジェクトを構築する。

[noexcept, since 6.5] QCryptographicHash::QCryptographicHash(QCryptographicHash &&other)

移動-other から新しい QCryptographicHash を構築する。

注意: 移動元のオブジェクトother は、部分的に形成された状態に置かれます。この状態では、有効な操作は破壊と新しい値の割り当てのみです。

この関数は Qt 6.5 で導入されました。

[noexcept] QCryptographicHash::~QCryptographicHash()

オブジェクトを破壊する。

[noexcept] void QCryptographicHash::addData(QByteArrayView bytes)

bytes の文字を暗号ハッシュに追加する。

注意: Qt 6.3 より前のバージョンでは、この関数はQByteArrayView ではなくQByteArray を取っていました。

bool QCryptographicHash::addData(QIODevice *device)

開いているQIODevice device から終了するまでデータを読み込み、ハッシュ化する。読み込みに成功した場合はtrue を返す。

[noexcept, since 6.5] QCryptographicHash::Algorithm QCryptographicHash::algorithm() const

暗号ハッシュの生成に使用したアルゴリズムを返します。

この関数は Qt 6.5 で導入されました。

[static] QByteArray QCryptographicHash::hash(QByteArrayView data, QCryptographicHash::Algorithm method)

method を使ってdata のハッシュを返す。

注意: Qt 6.3 より前のバージョンでは、この関数はQByteArrayView ではなくQByteArray を取っていました。

hashInto()も参照してください

[static] int QCryptographicHash::hashLength(QCryptographicHash::Algorithm method)

選択したハッシュmethod の出力サイズをバイト単位で返します。

[noexcept] void QCryptographicHash::reset()

オブジェクトをリセットする。

QByteArray QCryptographicHash::result() const

最終的なハッシュ値を返す。

resultView() およびQByteArray::toHex()も参照

[noexcept, since 6.3] QByteArrayView QCryptographicHash::resultView() const

最終的なハッシュ値を返す。

返されたビューは、QCryptographicHash オブジェクトが他の手段で変更されない限り有効であることに注意してください。

この関数は Qt 6.3 で導入されました。

result()も参照してください

[static, since 6.5] bool QCryptographicHash::supportsAlgorithm(QCryptographicHash::Algorithm method)

選択されたアルゴリズムmethod がサポートされているかどうか、またresult() がmethod を使用する場合に値を返すかどうかを返します。

注意: OpenSSLがプロバイダとして使用されている場合は、OpenSSLがこの情報を提供する責任を負います。そうでない場合は、OpenSSL以外の実装には制限がないため、true 。OpenSSL への問い合わせに失敗した場合はfalse を返します。

この関数は Qt 6.5 で導入されました。

[noexcept, since 6.5] void QCryptographicHash::swap(QCryptographicHash &other)

この暗号ハッシュをother と交換する。この操作は非常に高速で、失敗することはありません。

この関数は Qt 6.5 で導入されました。

[noexcept, since 6.5] QCryptographicHash &QCryptographicHash::operator=(QCryptographicHash &&other)

Move-assignother をこのQCryptographicHash インスタンスに割り当てる。

注意: 移動元のオブジェクトother は、部分的に形成された状態に置かれます。この状態では、有効な操作は破壊と新しい値の割り当てだけです。

この関数は Qt 6.5 で導入されました。

© 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.