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 ) | |
(從 6.5 起)
|
QCryptographicHash (QCryptographicHash && other ) |
| ~QCryptographicHash () | |
| void | addData (QByteArrayView bytes ) |
| bool | addData (QIODevice * device ) |
(從 6.5 起)
QCryptographicHash::Algorithm
|
algorithm () const |
| void | reset () |
| QByteArray | result () const |
(從 6.3 起)
QByteArrayView
|
resultView () const |
(從 6.5 起)
void
|
swap (QCryptographicHash & other ) |
(從 6.5 起)
QCryptographicHash &
|
operator= (QCryptographicHash && other ) |
| QByteArray | hash (QByteArrayView data , QCryptographicHash::Algorithm method ) |
(從 6.8 起)
QByteArrayView
|
hashInto (QSpan<char> buffer , QByteArrayView data , QCryptographicHash::Algorithm method ) |
(從 6.8 起)
QByteArrayView
|
hashInto (QSpan<char> buffer , QSpan<const QByteArrayView> data , QCryptographicHash::Algorithm method ) |
(從 6.8 起)
QByteArrayView
|
hashInto (QSpan<std::byte> buffer , QByteArrayView data , QCryptographicHash::Algorithm method ) |
(從 6.8 起)
QByteArrayView
|
hashInto (QSpan<std::byte> buffer , QSpan<const QByteArrayView> data , QCryptographicHash::Algorithm method ) |
(從 6.8 起)
QByteArrayView
|
hashInto (QSpan<uchar> buffer , QByteArrayView data , QCryptographicHash::Algorithm method ) |
(從 6.8 起)
QByteArrayView
|
hashInto (QSpan<uchar> buffer , QSpan<const QByteArrayView> data , QCryptographicHash::Algorithm method ) |
| int | hashLength (QCryptographicHash::Algorithm method ) |
(從 6.5 起)
bool
|
supportsAlgorithm (QCryptographicHash::Algorithm method ) |
QCryptographicHash 可用於生成二進製 (或文本數據) 的加密哈希。
參考文檔編製中 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::Blake2b_160
|
15
|
Generate a BLAKE2b-160 hash sum. Introduced in Qt 6.0 |
QCryptographicHash::Blake2b_256
|
16
|
Generate a BLAKE2b-256 hash sum. Introduced in Qt 6.0 |
QCryptographicHash::Blake2b_384
|
17
|
Generate a BLAKE2b-384 hash sum. Introduced in Qt 6.0 |
QCryptographicHash::Blake2b_512
|
18
|
Generate a BLAKE2b-512 hash sum. Introduced in Qt 6.0 |
QCryptographicHash::Blake2s_128
|
19
|
Generate a BLAKE2s-128 hash sum. Introduced in Qt 6.0 |
QCryptographicHash::Blake2s_160
|
20
|
Generate a BLAKE2s-160 hash sum. Introduced in Qt 6.0 |
QCryptographicHash::Blake2s_224
|
21
|
Generate a BLAKE2s-224 hash sum. Introduced in Qt 6.0 |
QCryptographicHash::Blake2s_256
|
22
|
Generate a BLAKE2s-256 hash sum. Introduced in 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
)
返迴哈希為 data 使用 method ,使用 buffer to store the result.
若 data is a span, adds all the byte array views to the hash, in the order given.
The return value will be a sub-span of buffer , unless buffer is of insufficient size, in which case a null QByteArrayView 被返迴。
這些函數在 Qt 6.8 引入。
另請參閱 hash ().
[explicit]
QCryptographicHash::
QCryptographicHash
(
QCryptographicHash::Algorithm
method
)
構造可用於從數據創建加密哈希的對象,使用 method .
[noexcept, since 6.5]
QCryptographicHash::
QCryptographicHash
(
QCryptographicHash
&&
other
)
Move-constructs a new QCryptographicHash from other .
注意: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.
該函數在 Qt 6.5 引入。
[noexcept]
QCryptographicHash::
~QCryptographicHash
()
銷毀對象。
[noexcept]
void
QCryptographicHash::
addData
(
QByteArrayView
bytes
)
Adds the characters in bytes to the cryptographic hash.
注意: In Qt versions prior to 6.3, this function took QByteArray , not QByteArrayView .
讀取數據,從打開
QIODevice
device
直到它結束並哈希為止。返迴
true
若讀取是成功的。
[noexcept, since 6.5]
QCryptographicHash::Algorithm
QCryptographicHash::
algorithm
() const
Returns the algorithm used to generate the cryptographic hash.
該函數在 Qt 6.5 引入。
[static]
QByteArray
QCryptographicHash::
hash
(
QByteArrayView
data
,
QCryptographicHash::Algorithm
method
)
返迴哈希為 data 使用 method .
注意: In Qt versions prior to 6.3, this function took QByteArray , not QByteArrayView .
另請參閱 hashInto ().
[static]
int
QCryptographicHash::
hashLength
(
QCryptographicHash::Algorithm
method
)
Returns the size of the output of the selected hash method in bytes.
[noexcept]
void
QCryptographicHash::
reset
()
重置對象。
返迴最終的哈希值。
另請參閱 resultView () 和 QByteArray::toHex ().
[noexcept, since 6.3]
QByteArrayView
QCryptographicHash::
resultView
() const
返迴最終的哈希值。
Note that the returned view remains valid only as long as the QCryptographicHash object is not modified by other means.
該函數在 Qt 6.3 引入。
另請參閱 result ().
[static, since 6.5]
bool
QCryptographicHash::
supportsAlgorithm
(
QCryptographicHash::Algorithm
method
)
Returns whether the selected algorithm method is supported and if result () will return a value when the method 被使用。
注意:
OpenSSL will be responsible for providing this information when used as a provider, otherwise
true
will be returned as the non-OpenSSL implementation doesn't have any restrictions. We return
false
if we fail to query OpenSSL.
該函數在 Qt 6.5 引入。
[noexcept, since 6.5]
void
QCryptographicHash::
swap
(
QCryptographicHash
&
other
)
Swaps this cryptographic hash with other 。此操作很快且從不失敗。
該函數在 Qt 6.5 引入。
[noexcept, since 6.5]
QCryptographicHash
&QCryptographicHash::
operator=
(
QCryptographicHash
&&
other
)
移動賦值 other 到此 QCryptographicHash 實例。
注意: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.
該函數在 Qt 6.5 引入。