QPasswordDigestor namespace contains functions which you can use to generate hashes or keys. 更多 …
New in version 5.12.
def
deriveKeyPbkdf1
(algorithm, password, salt, iterations, dkLen)
def
deriveKeyPbkdf2
(algorithm, password, salt, iterations, dkLen)
PySide2.QtNetwork.QPasswordDigestor.
deriveKeyPbkdf1
(
algorithm
,
password
,
salt
,
iterations
,
dkLen
)
¶
algorithm
–
Algorithm
password
–
QByteArray
salt
–
QByteArray
iterations
–
int
dkLen
–
quint64
QByteArray
Returns a hash computed using the PBKDF1-algorithm as defined in RFC 8018 .
The function takes the
data
and
salt
, and then hashes it repeatedly for
iterations
iterations using the specified hash
algorithm
. If the resulting hash is longer than
dkLen
then it is truncated before it is returned.
This function only supports SHA-1 and MD5! The max output size is 160 bits (20 bytes) when using SHA-1, or 128 bits (16 bytes) when using MD5. Specifying a value for
dkLen
which is greater than this results in a warning and an empty
QByteArray
is returned. To programmatically check this limit you can use
hashLength
. Furthermore: the
salt
must always be 8 bytes long!
注意
This function is provided for use with legacy applications and all new applications are recommended to use
PBKDF2
.
另请参阅
deriveKeyPbkdf2
QCryptographicHash
hashLength
PySide2.QtNetwork.QPasswordDigestor.
deriveKeyPbkdf2
(
algorithm
,
password
,
salt
,
iterations
,
dkLen
)
¶
algorithm
–
Algorithm
password
–
QByteArray
salt
–
QByteArray
iterations
–
int
dkLen
–
quint64
QByteArray
Derive a key using the PBKDF2-algorithm as defined in RFC 8018 .
This function takes the
data
and
salt
, and then applies HMAC-X, where the X is
algorithm
, repeatedly. It internally concatenates intermediate results to the final output until at least
dkLen
amount of bytes have been computed and it will execute HMAC-X
iterations
times each time a concatenation is required. The total number of times it will execute HMAC-X depends on
iterations
,
dkLen
and
algorithm
and can be calculated as
iterations
*
ceil(dkLen
/
QCryptographicHash::hashLength(algorithm))
.