Logo

Cake Planner

Backend

password_utils.cpp

File Header Information

FieldValue
SPDX CommentPassword Hashing Utilities
SPDX TypeSOURCE
ContributorZHENG Robert
License IDMIT
Filepassword_utils.cpp
DescriptionPassword Hashing Utilities
Version0.15.0
Date2026-01-24
AuthorZHENG Robert (robert@hase-zheng.net)
CopyrightCopyright (c) 2026 ZHENG Robert
LicenseMIT

Table of Contents

API Documentation

namespace utils

utils namespace.


QString PasswordUtils::hashPassword(const QString &plainText)

Hashes a plain text password using Argon2id.

ParameterDescription
plainTextThe password to hash.

Returns: The encoded hash string (including salt and parameters) or empty string on failure.


std::uniform_int_distribution dist(0, 255)

Function implementation.


std::vector encoded(encodedLen)

Function implementation.


bool PasswordUtils::verifyPassword(const QString &plainText,

Verifies a password against an encoded hash.

ParameterDescription
plainTextThe plain text password to verify.
encodedHashThe Argon2id encoded hash to verify against.

Returns: True if the password matches, false otherwise.


QString PasswordUtils::generateRandomPassword(int length)

Generates a random password.

ParameterDescription
lengthLength of the password.

Returns: Random string.


std::uniform_int_distribution distribution(0, max_index - 1)

Function implementation.