mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-26 22:36:59 -05:00
add default charset when not specified
explicitly state the wordcount default value
This commit is contained in:
parent
e9612ee9e6
commit
e57a2e0fa9
@ -133,8 +133,7 @@ int Add::execute(QStringList arguments)
|
|||||||
passwordGenerator.setLength(passwordLength.toInt());
|
passwordGenerator.setLength(passwordLength.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
passwordGenerator.setCharClasses(PasswordGenerator::LowerLetters | PasswordGenerator::UpperLetters |
|
passwordGenerator.setCharClasses(PasswordGenerator::DefaultCharset);
|
||||||
PasswordGenerator::Numbers);
|
|
||||||
QString password = passwordGenerator.generatePassword();
|
QString password = passwordGenerator.generatePassword();
|
||||||
entry->setPassword(password);
|
entry->setPassword(password);
|
||||||
}
|
}
|
||||||
|
@ -149,8 +149,7 @@ int Edit::execute(QStringList arguments)
|
|||||||
passwordGenerator.setLength(passwordLength.toInt());
|
passwordGenerator.setLength(passwordLength.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
passwordGenerator.setCharClasses(PasswordGenerator::LowerLetters | PasswordGenerator::UpperLetters |
|
passwordGenerator.setCharClasses(PasswordGenerator::DefaultCharset);
|
||||||
PasswordGenerator::Numbers);
|
|
||||||
QString password = passwordGenerator.generatePassword();
|
QString password = passwordGenerator.generatePassword();
|
||||||
entry->setPassword(password);
|
entry->setPassword(password);
|
||||||
}
|
}
|
||||||
|
@ -96,12 +96,7 @@ int PassGen::execute(QStringList arguments)
|
|||||||
classes |= PasswordGenerator::EASCII;
|
classes |= PasswordGenerator::EASCII;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classes == 0x0) {
|
passwordGenerator.setCharClasses(classes);
|
||||||
passwordGenerator.setCharClasses(PasswordGenerator::LowerLetters | PasswordGenerator::UpperLetters |
|
|
||||||
PasswordGenerator::Numbers);
|
|
||||||
} else {
|
|
||||||
passwordGenerator.setCharClasses(classes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!passwordGenerator.isValid()) {
|
if (!passwordGenerator.isValid()) {
|
||||||
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli passgen");
|
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli passgen");
|
||||||
|
@ -48,7 +48,7 @@ void PassphraseGenerator::setWordCount(int wordCount)
|
|||||||
m_wordCount = wordCount;
|
m_wordCount = wordCount;
|
||||||
} else {
|
} else {
|
||||||
// safe default if something goes wrong
|
// safe default if something goes wrong
|
||||||
m_wordCount = 7;
|
m_wordCount = DefaultWordCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
|
|
||||||
QString generatePassphrase() const;
|
QString generatePassphrase() const;
|
||||||
|
|
||||||
|
static const int DefaultWordCount = 7;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_wordCount;
|
int m_wordCount;
|
||||||
QString m_separator;
|
QString m_separator;
|
||||||
|
@ -35,11 +35,19 @@ double PasswordGenerator::calculateEntropy(QString password)
|
|||||||
|
|
||||||
void PasswordGenerator::setLength(int length)
|
void PasswordGenerator::setLength(int length)
|
||||||
{
|
{
|
||||||
|
if (length <= 0) {
|
||||||
|
m_length = DefaultLength;
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_length = length;
|
m_length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasswordGenerator::setCharClasses(const CharClasses& classes)
|
void PasswordGenerator::setCharClasses(const CharClasses& classes)
|
||||||
{
|
{
|
||||||
|
if (classes == 0) {
|
||||||
|
m_classes = DefaultCharset;
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_classes = classes;
|
m_classes = classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ public:
|
|||||||
UpperLetters = 0x2,
|
UpperLetters = 0x2,
|
||||||
Numbers = 0x4,
|
Numbers = 0x4,
|
||||||
SpecialCharacters = 0x8,
|
SpecialCharacters = 0x8,
|
||||||
EASCII = 0x10
|
EASCII = 0x10,
|
||||||
|
DefaultCharset = LowerLetters | UpperLetters | Numbers
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(CharClasses, CharClass)
|
Q_DECLARE_FLAGS(CharClasses, CharClass)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user