Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/PasswordGenerator.cpp')
-rw-r--r--src/core/PasswordGenerator.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/core/PasswordGenerator.cpp b/src/core/PasswordGenerator.cpp
index e203af672..efe647880 100644
--- a/src/core/PasswordGenerator.cpp
+++ b/src/core/PasswordGenerator.cpp
@@ -19,23 +19,19 @@
#include "PasswordGenerator.h"
#include "crypto/Random.h"
-#include <zxcvbn.h>
+const char* PasswordGenerator::DefaultAdditionalChars = "";
const char* PasswordGenerator::DefaultExcludedChars = "";
PasswordGenerator::PasswordGenerator()
: m_length(0)
, m_classes(nullptr)
, m_flags(nullptr)
+ , m_additional(PasswordGenerator::DefaultAdditionalChars)
, m_excluded(PasswordGenerator::DefaultExcludedChars)
{
}
-double PasswordGenerator::estimateEntropy(const QString& password)
-{
- return ZxcvbnMatch(password.toLatin1(), nullptr, nullptr);
-}
-
void PasswordGenerator::setLength(int length)
{
if (length <= 0) {
@@ -59,6 +55,11 @@ void PasswordGenerator::setFlags(const GeneratorFlags& flags)
m_flags = flags;
}
+void PasswordGenerator::setAdditionalChars(const QString& chars)
+{
+ m_additional = chars;
+}
+
void PasswordGenerator::setExcludedChars(const QString& chars)
{
m_excluded = chars;
@@ -113,7 +114,7 @@ QString PasswordGenerator::generatePassword() const
bool PasswordGenerator::isValid() const
{
- if (m_classes == 0) {
+ if (m_classes == 0 && m_additional.isEmpty()) {
return false;
} else if (m_length == 0) {
return false;
@@ -265,6 +266,15 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups() const
passwordGroups.append(group);
}
+ if (!m_additional.isEmpty()) {
+ PasswordGroup group;
+
+ for (auto ch : m_additional) {
+ group.append(ch);
+ }
+
+ passwordGroups.append(group);
+ }
// Loop over character groups and remove excluded characters from them;
// remove empty groups