* @brief Hashes @p plain with PBKDF2-SHA256 and returns a PHC-style `pbkdf2-sha256$iter$salt$hash`. */
| 70 | * @brief Hashes @p plain with PBKDF2-SHA256 and returns a PHC-style `pbkdf2-sha256$iter$salt$hash`. |
| 71 | */ |
| 72 | QString Misc::PasswordHash::hashPassword(const QString& plain) |
| 73 | { |
| 74 | const auto salt = randomSalt(); |
| 75 | const auto derived = derivePbkdf2(plain.toUtf8(), salt, kPbkdf2Iterations); |
| 76 | |
| 77 | return QStringLiteral("pbkdf2-sha256$%1$%2$%3") |
| 78 | .arg(kPbkdf2Iterations) |
| 79 | .arg(QString::fromLatin1(salt.toBase64(QByteArray::OmitTrailingEquals))) |
| 80 | .arg(QString::fromLatin1(derived.toBase64(QByteArray::OmitTrailingEquals))); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @brief Verifies @p plain against @p storedHash, accepting both the PBKDF2 format and legacy MD5. |
nothing calls this directly
no test coverage detected