QPasswordDigestor Namespace
El espacio de nombres QPasswordDigestor contiene funciones que puedes utilizar para generar hash o claves. Más información...
| Encabezado: | #include <QPasswordDigestor> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
Funciones
| 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) |
Documentación de funciones
QByteArray QPasswordDigestor::deriveKeyPbkdf1(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)
Devuelve un hash calculado mediante el algoritmo PBKDF1 , tal y como se define en la sección 5.1 del RFC 8018.
La función toma los valores de « data » y « salt » y, a continuación, aplica el hash repetidamente durante « iterations » iteraciones utilizando el hash especificado « algorithm ». Si el hash resultante es más largo que « dkLen », se trunca antes de ser devuelto.
¡Esta función solo admite SHA-1 y MD5! El tamaño máximo de salida es de 160 bits (20 bytes) cuando se utiliza SHA-1, o de 128 bits (16 bytes) cuando se utiliza MD5. Si se especifica un valor para dkLen superior a este límite, se muestra una advertencia y se devuelve un QByteArray vacío. Para comprobar este límite mediante programación, puedes utilizar ` QCryptographicHash::hashLength`. Además: ¡el ` salt ` debe tener siempre una longitud de 8 bytes!
Nota: Esta función se proporciona para su uso con aplicaciones heredadas; se recomienda que todas las aplicaciones nuevas utilicen PBKDF2.
Véase también deriveKeyPbkdf2, QCryptographicHash y QCryptographicHash::hashLength.
QByteArray QPasswordDigestor::deriveKeyPbkdf2(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)
Deriva una clave utilizando el algoritmo PBKDF2 tal y como se define en la RFC 8018, sección 5.2.
Esta función toma data y salt, y a continuación aplica HMAC-X —donde X es algorithm — de forma repetida. Concatena internamente los resultados intermedios a la salida final hasta que se haya calculado al menos una cantidad de bytes dkLen, y ejecutará HMAC-X iterations veces cada vez que se requiera una concatenación. El número total de veces que se ejecutará HMAC-X depende de iterations, dkLen y algorithm, y puede calcularse como iterations * ceil(dkLen / QCryptographicHash::hashLength(algorithm)).
Véase también deriveKeyPbkdf1, QMessageAuthenticationCode y 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.