Remove legacy hashes

This commit is contained in:
gabdevele
2026-06-02 20:37:06 +02:00 Unverified
parent 77744d9174
commit b59536757b
5 changed files with 5 additions and 22 deletions
-16
View File
@@ -79,24 +79,8 @@ std::string hashPassword(const std::string &password)
bool verifyPassword(const std::string &password, const std::string &hash)
{
constexpr std::string_view legacyPrefix = "sha256$";
constexpr std::string_view pbkdf2Prefix = "pbkdf2_sha256$";
if (hash.starts_with(legacyPrefix))
{
const auto saltStart = legacyPrefix.size();
const auto hashStart = hash.find('$', saltStart);
if (hashStart == std::string::npos)
{
return false;
}
const auto salt = hash.substr(saltStart, hashStart - saltStart);
const auto expected =
"sha256$" + salt + "$" + sha256(salt + ":" + password);
return expected == hash;
}
if (!hash.starts_with(pbkdf2Prefix))
{
return false;