<commit_before>#include "Auth.hpp"

#include <QDebug>
#include <QDateTime>

namespace cutehmi {
namespace lockscreen {

Auth::Auth(QObject * parent) : QObject(parent),
    m_lowerBoundOfHashes(9000), m_upperBoundOfHashes(10000), m_locked(false)
{
    m_settings = new QSettings(this);
	m_settings->beginGroup("cutehmi_lockscreen_1");
    qsrand(static_cast<uint>(QTime::currentTime().msec()));
}

bool Auth::checkPassword(const QString & password)
{
    if (validatePassword(password) != true)
        return false;
    QString passwordHash = m_settings->value("lockScreenPassword").toString();
    QByteArray hash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Sha3_512).toHex();
    for (int i = 0; i < m_upperBoundOfHashes; ++i) {
        if (i >= m_lowerBoundOfHashes && hash == passwordHash)
            return true;
        hash = QCryptographicHash::hash(hash, QCryptographicHash::Sha3_512).toHex();
    }
    return false;
}

bool Auth::validatePassword(const QString & password)
{
    if (password.length() != 0)
        return true;
    return false;
}

bool Auth::changePassword(const QString & newPassword, const QString & oldPassword)
{
    if (checkPassword(oldPassword)) {
        changePassword(newPassword);
        return true;
    }
    return false;
}

void Auth::changePassword(const QString & password)
{
    if (validatePassword(password) != true)
        return;
    QByteArray hash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Sha3_512).toHex();
    for (int i = 0; i < getNumberOfHashes(); ++i)
        hash = QCryptographicHash::hash(hash, QCryptographicHash::Sha3_512).toHex();
    QString passwordHash = hash;
    m_settings->setValue("lockScreenPassword", passwordHash);
}<commit_msg>Change name of LockScreenPassword setting to just password.<commit_after>#include "Auth.hpp"

#include <QDebug>
#include <QDateTime>

namespace cutehmi {
namespace lockscreen {

Auth::Auth(QObject * parent) : QObject(parent),
    m_lowerBoundOfHashes(9000), m_upperBoundOfHashes(10000), m_locked(false)
{
    m_settings = new QSettings(this);
	m_settings->beginGroup("cutehmi_lockscreen_1");
    qsrand(static_cast<uint>(QTime::currentTime().msec()));
}

bool Auth::checkPassword(const QString & password)
{
    if (validatePassword(password) != true)
        return false;
	QString passwordHash = m_settings->value("password").toString();
    QByteArray hash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Sha3_512).toHex();
    for (int i = 0; i < m_upperBoundOfHashes; ++i) {
        if (i >= m_lowerBoundOfHashes && hash == passwordHash)
            return true;
        hash = QCryptographicHash::hash(hash, QCryptographicHash::Sha3_512).toHex();
    }
    return false;
}

bool Auth::validatePassword(const QString & password)
{
    if (password.length() != 0)
        return true;
    return false;
}

bool Auth::changePassword(const QString & newPassword, const QString & oldPassword)
{
    if (checkPassword(oldPassword)) {
        changePassword(newPassword);
        return true;
    }
    return false;
}

void Auth::changePassword(const QString & password)
{
    if (validatePassword(password) != true)
        return;
    QByteArray hash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Sha3_512).toHex();
    for (int i = 0; i < getNumberOfHashes(); ++i)
        hash = QCryptographicHash::hash(hash, QCryptographicHash::Sha3_512).toHex();
    QString passwordHash = hash;
	m_settings->setValue("password", <PASSWORD>);
}
{'fraction_non_alphanumeric': 0.13017583664208734, 'fraction_numerical': 0.01758366420873511, 'mean_word_length': 4.485225505443235, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '10176', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1100, 'n_words': 223}