MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / hashPassword

Method hashPassword

app/src/Misc/PasswordHash.cpp:72–81  ·  view source on GitHub ↗

* @brief Hashes @p plain with PBKDF2-SHA256 and returns a PHC-style `pbkdf2-sha256$iter$salt$hash`. */

Source from the content-addressed store, hash-verified

70 * @brief Hashes @p plain with PBKDF2-SHA256 and returns a PHC-style `pbkdf2-sha256$iter$salt$hash`.
71 */
72QString 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.

Callers

nothing calls this directly

Calls 2

randomSaltFunction · 0.85
derivePbkdf2Function · 0.85

Tested by

no test coverage detected