Kirigami-addons
4#include "passwordhealth.h"
5#include "zxcvbn/zxcvbn.h"
7constexpr static int ZXCVBN_ESTIMATE_THRESHOLD = 256;
9PasswordHealth::PasswordHealth(
QObject *parent)
13QString PasswordHealth::password()
const
18void PasswordHealth::setPassword(
const QString &password)
20 if (m_password == password) {
23 m_password = password;
26 entropy += ZxcvbnMatch(m_password.left(ZXCVBN_ESTIMATE_THRESHOLD).toUtf8().data(),
nullptr,
nullptr);
27 if (m_password.length() > ZXCVBN_ESTIMATE_THRESHOLD) {
29 auto average = entropy / ZXCVBN_ESTIMATE_THRESHOLD;
30 entropy += average * (m_password.length() - ZXCVBN_ESTIMATE_THRESHOLD);
37double PasswordHealth::entropy()
const
42PasswordHealth::Quality PasswordHealth::quality()
const
46 }
else if (m_entropy < 40) {
48 }
else if (m_entropy < 75) {
50 }
else if (m_entropy < 100) {
53 return Quality::Excellent;
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 28 2025 11:51:42 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.