The QCryptographicHash class provides a way to generate cryptographic hashes. 更多...
| 頭: | #include <QCryptographicHash> |
| qmake: | QT += core |
| Since: | Qt 4.3 |
注意: 此類的所有函數 可重入 .
| enum | Algorithm { Md4, Md5, Sha1, Sha224, ..., 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 ) |
| const QMetaObject | staticMetaObject |
The QCryptographicHash class provides a way to generate cryptographic hashes.
QCryptographicHash can be used to generate cryptographic hashes of binary or text data.
參考文檔編製中 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 |
構造可用於從數據創建加密哈希的對象,使用 method .
銷毀對象。
Adds the first length chars of data to the cryptographic hash.
此函數重載 addData ().
讀取數據,從打開
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 引入。
重置對象。
返迴最終的哈希值。
另請參閱 QByteArray::toHex ().