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