QPasswordDigestor Namespace
Lo spazio dei nomi QPasswordDigestor contiene funzioni che è possibile utilizzare per generare hash o chiavi. Maggiori informazioni...
| Intestazione: | #include <QPasswordDigestor> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
Funzioni
| 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) |
Documentazione delle funzioni
QByteArray QPasswordDigestor::deriveKeyPbkdf1(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)
Restituisce un hash calcolato utilizzando l'algoritmo PBKDF1 , come definito nella RFC 8018, sezione 5.1.
La funzione accetta i parametri data e salt e, successivamente, esegue ripetutamente l'hash per iterations iterazioni utilizzando l'hash specificato algorithm. Se l'hash risultante è più lungo di dkLen, viene troncato prima di essere restituito.
Questa funzione supporta solo SHA-1 e MD5! La dimensione massima dell’output è di 160 bit (20 byte) quando si utilizza SHA-1, oppure di 128 bit (16 byte) quando si utilizza MD5. Specificare un valore per dkLen superiore a questo limite genera un avviso e viene restituito un QByteArray vuoto. Per verificare a livello di programmazione questo limite è possibile utilizzare ` QCryptographicHash::hashLength`. Inoltre: l’ salt e deve sempre avere una lunghezza di 8 byte!
Nota: questa funzione è fornita per l’uso con applicazioni legacy; per tutte le nuove applicazioni si raccomanda di utilizzare PBKDF2.
Vedi anche deriveKeyPbkdf2, QCryptographicHash e QCryptographicHash::hashLength.
QByteArray QPasswordDigestor::deriveKeyPbkdf2(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)
Generare una chiave utilizzando l'algoritmo PBKDF2, come definito nella RFC 8018, sezione 5.2.
Questa funzione accetta data e salt, quindi applica ripetutamente HMAC-X, dove X è algorithm. Concatena internamente i risultati intermedi all'output finale fino a quando non è stata calcolata una quantità di byte pari almeno a dkLen ed eseguirà HMAC-X iterations volte ogni volta che è richiesta una concatenazione. Il numero totale di volte in cui verrà eseguito HMAC-X dipende da iterations, dkLen e algorithm e può essere calcolato come iterations * ceil(dkLen / QCryptographicHash::hashLength(algorithm)).
Vedi anche 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.