QPasswordDigestor Namespace
O namespace QPasswordDigestor contém funções que você pode usar para gerar hashes ou chaves. Saiba mais...
| Cabeçalho: | #include <QPasswordDigestor> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
Funções
| QByteArray | deriveKeyPbkdf1(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen) |
| QByteArray | deriveKeyPbkdf2(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen) |
Documentação das funções
QByteArray QPasswordDigestor::deriveKeyPbkdf1(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)
Retorna um hash calculado usando o algoritmo PBKDF1 , conforme definido na RFC 8018, seção 5.1.
A função recebe os parâmetros ` data ` e ` salt` e, em seguida, aplica o hash repetidamente por ` iterations ` iterações, utilizando o hash especificado ` algorithm`. Se o hash resultante for maior que ` dkLen `, ele será truncado antes de ser retornado.
Esta função suporta apenas SHA-1 e MD5! O tamanho máximo de saída é de 160 bits (20 bytes) ao usar SHA-1, ou 128 bits (16 bytes) ao usar MD5. Especificar um valor para dkLen maior do que isso resulta em um aviso e um QByteArray vazio é retornado. Para verificar esse limite programaticamente, você pode usar ` QCryptographicHash::hashLength`. Além disso: o ` salt ` deve ter sempre 8 bytes de comprimento!
Observação: essa função é fornecida para uso com aplicativos legados, e recomenda-se que todos os novos aplicativos utilizem PBKDF2.
Veja também deriveKeyPbkdf2, QCryptographicHash e QCryptographicHash::hashLength.
QByteArray QPasswordDigestor::deriveKeyPbkdf2(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)
Gerar uma chave utilizando o algoritmo PBKDF2 , conforme definido na RFC 8018, seção 5.2.
Essa função recebe os parâmetros data e salt e, em seguida, aplica o HMAC-X — onde X representa algorithm — repetidamente. Ela concatena internamente os resultados intermediários à saída final até que pelo menos uma quantidade de bytes dkLen tenha sido calculada e executará o HMAC-X iterations vezes sempre que for necessária uma concatenação. O número total de vezes que o HMAC-X será executado depende de iterations, dkLen e algorithm e pode ser calculado como iterations * ceil(dkLen / QCryptographicHash::hashLength(algorithm)).
Veja também deriveKeyPbkdf1, QMessageAuthenticationCode e QCryptographicHash.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.