En esta página

QPasswordDigestor Namespace

El espacio de nombres QPasswordDigestor contiene funciones que puedes usar para generar hashes o claves. Más...

Cabecera: #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)

Descripción Detallada

Documentación de funciones

QByteArray QPasswordDigestor::deriveKeyPbkdf1(QCryptographicHash::Algorithm algorithm, const QByteArray &data, const QByteArray &salt, int iterations, quint64 dkLen)

Devuelve un hash calculado utilizando el algoritmo PBKDF1 definido en RFC 8018, sección 5.1.

La función toma los datos data y salt, y luego los hashea repetidamente por iterations iteraciones usando el hash especificado algorithm. Si el hash resultante es más largo que dkLen entonces se trunca antes de ser devuelto.

Esta función sólo admite SHA-1 y MD5. El tamaño máximo de salida es de 160 bits (20 bytes) si se utiliza SHA-1, o de 128 bits (16 bytes) si se utiliza MD5. Si se especifica un valor para dkLen superior a este límite, se produce una advertencia y se devuelve un QByteArray vacío. Para comprobar este límite mediante programación, puede utilizar QCryptographicHash::hashLength. Además: salt debe tener siempre una longitud de 8 bytes.

Nota: Esta función se proporciona para su uso con aplicaciones heredadas y 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)

Derivar una clave utilizando el algoritmo PBKDF2 definido en RFC 8018, sección 5.2.

Esta función toma los data y salt, y luego aplica HMAC-X, donde la X es algorithm, repetidamente. Internamente concatena resultados intermedios a la salida final hasta que al menos dkLen cantidad de bytes han sido computados y ejecutará HMAC-X iterations veces cada vez que se requiera una concatenación. El número total de veces que 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.