QCryptographicHash 類

QCryptographicHash 類提供生成加密哈希的辦法。 更多...

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

該類在 Qt 4.3 引入。

注意: 此類的所有函數 可重入 .

公共類型

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

公共函數

QCryptographicHash (QCryptographicHash::Algorithm method )
~QCryptographicHash ()
void addData (const char * data , int length )
void addData (const QByteArray & data )
bool addData (QIODevice * device )
void reset ()
QByteArray result () const

靜態公共成員

QByteArray hash (const QByteArray & data , QCryptographicHash::Algorithm method )
int hashLength (QCryptographicHash::Algorithm method )

詳細描述

QCryptographicHash 可用於生成二進製 (或文本數據) 的加密哈希。

參考文檔編製中 QCryptographicHash::Algorithm 枚舉,支持的算法列錶。

成員類型文檔編製

enum QCryptographicHash:: Algorithm

注意: In Qt versions before 5.9, when asked to generate a SHA3 hash sum, QCryptographicHash actually calculated Keccak. If you need compatibility with SHA-3 hashes produced by those versions of Qt, use the Keccak_ enumerators. Alternatively, if source compatibility is required, define the macro QT_SHA3_KECCAK_COMPAT .

常量 描述
QCryptographicHash::Md4 0 生成 MD4 哈希和
QCryptographicHash::Md5 1 生成 MD5 哈希和
QCryptographicHash::Sha1 2 生成 SHA-1 哈希和
QCryptographicHash::Sha224 3 生成 SHA-224 哈希和 (SHA-2)。在 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

成員函數文檔編製

QCryptographicHash:: QCryptographicHash ( QCryptographicHash::Algorithm method )

構造可用於從數據創建加密哈希的對象,使用 method .

QCryptographicHash:: ~QCryptographicHash ()

銷毀對象。

void QCryptographicHash:: addData (const char * data , int length )

Adds the first length chars of data to the cryptographic hash.

void QCryptographicHash:: addData (const QByteArray & data )

此函數重載 addData()。

bool QCryptographicHash:: addData ( QIODevice * device )

讀取數據,從打開 QIODevice device 直到它結束並哈希為止。返迴 true 若讀取是成功的。

該函數在 Qt 5.0 引入。

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

返迴哈希為 data 使用 method .

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

Returns the size of the output of the selected hash method in bytes.

該函數在 Qt 5.12 引入。

void QCryptographicHash:: reset ()

重置對象。

QByteArray QCryptographicHash:: result () const

返迴最終的哈希值。

另請參閱 QByteArray::toHex ().