PySide6.QtCore.QCryptographicHash¶
- class QCryptographicHash¶
QCryptographicHash
类提供了一种生成加密哈希的方法。更多…概要¶
方法¶
def
__init__()
def
addData()
def
algorithm()
def
reset()
def
result()
def
resultView()
def
swap()
静态函数¶
def
hash()
def
hashLength()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
QCryptographicHash
可用于生成二进制或文本数据的加密哈希值。请参考
Algorithm
枚举的文档以获取支持的算法列表。- class Algorithm¶
注意
在5.9之前的Qt版本中,当要求生成SHA3哈希值时,
QCryptographicHash
实际上计算的是Keccak。如果您需要与这些Qt版本生成的SHA-3哈希值兼容,请使用Keccak_
枚举器。或者,如果需要源代码兼容性,请定义宏QT_SHA3_KECCAK_COMPAT
。常量
描述
QCryptographicHash.Md4
生成一个MD4哈希值
QCryptographicHash.Md5
生成一个MD5哈希值
QCryptographicHash.Sha1
生成一个SHA-1哈希值
QCryptographicHash.Sha224
生成一个SHA-224哈希值(SHA-2)。在Qt 5.0中引入
QCryptographicHash.Sha256
生成一个SHA-256哈希值(SHA-2)。在Qt 5.0中引入
QCryptographicHash.Sha384
生成一个SHA-384哈希值(SHA-2)。在Qt 5.0中引入
QCryptographicHash.Sha512
生成一个SHA-512哈希值(SHA-2)。在Qt 5.0中引入
QCryptographicHash.Sha3_224
生成一个SHA3-224哈希值。在Qt 5.1中引入
QCryptographicHash.Sha3_256
生成一个SHA3-256哈希值。在Qt 5.1中引入
QCryptographicHash.Sha3_384
生成一个SHA3-384哈希值。在Qt 5.1中引入
QCryptographicHash.Sha3_512
生成一个SHA3-512哈希值。在Qt 5.1中引入
QCryptographicHash.Keccak_224
生成一个Keccak-224哈希值。在Qt 5.9.2中引入
QCryptographicHash.Keccak_256
生成一个Keccak-256哈希值。在Qt 5.9.2中引入
QCryptographicHash.Keccak_384
生成一个Keccak-384哈希值。在Qt 5.9.2中引入
QCryptographicHash.Keccak_512
生成一个Keccak-512哈希值。在Qt 5.9.2中引入
QCryptographicHash.Blake2b_160
生成一个BLAKE2b-160哈希值。在Qt 6.0中引入
QCryptographicHash.Blake2b_256
生成一个BLAKE2b-256哈希值。在Qt 6.0中引入
QCryptographicHash.Blake2b_384
生成一个BLAKE2b-384哈希值。在Qt 6.0中引入
QCryptographicHash.Blake2b_512
生成一个BLAKE2b-512哈希值。在Qt 6.0中引入
QCryptographicHash.Blake2s_128
生成一个BLAKE2s-128哈希值。在Qt 6.0中引入
QCryptographicHash.Blake2s_160
生成一个BLAKE2s-160哈希值。在Qt 6.0中引入
QCryptographicHash.Blake2s_224
生成一个BLAKE2s-224哈希值。在Qt 6.0中引入
QCryptographicHash.Blake2s_256
生成一个BLAKE2s-256哈希值。在Qt 6.0中引入
构造一个对象,该对象可用于使用
method
从数据创建加密哈希。- addData(data)¶
- Parameters:
数据 –
QByteArrayView
将
bytes
中的字符添加到加密哈希中。注意
在Qt 6.3之前的版本中,此函数接受的是
QByteArray
,而不是QByteArrayView
。- addData(device)
- Parameters:
设备 –
QIODevice
- Return type:
布尔
从打开的
QIODevice
device
中读取数据直到结束并对其进行哈希处理。如果读取成功,则返回true
。- addData(data)
- Parameters:
data – 字符串
注意
此函数已弃用。
将
data
的前length
个字符添加到加密哈希中。请改用
QByteArrayView
的重载。返回用于生成加密哈希的算法。
返回使用
method
对data
的哈希值。返回所选哈希
method
输出的大小(以字节为单位)。- reset()¶
重置对象。
- result()¶
- Return type:
返回最终的哈希值。
另请参阅
- resultView()¶
- Return type:
QByteArrayView
返回最终的哈希值。
请注意,返回的视图仅在
QCryptographicHash
对象未被其他方式修改时保持有效。另请参阅
返回所选算法
method
是否受支持,以及当使用method
时result()
是否会返回值。注意
当使用OpenSSL作为提供者时,OpenSSL将负责提供此信息,否则将返回
true
,因为非OpenSSL实现没有任何限制。如果我们无法查询OpenSSL,则返回false
。- swap(other)¶
- Parameters:
其他 –
QCryptographicHash
将此加密哈希与
other
加密哈希交换。此操作非常快速且永远不会失败。