mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-13 08:46:06 -04:00
Add advanced password generator features (#1841)
* Split between simple and advanced features * Finetune password character groups * Support for hex passwords
This commit is contained in:
parent
83917299db
commit
e124f17c64
11 changed files with 1100 additions and 217 deletions
|
@ -44,19 +44,41 @@ int Generate::execute(const QStringList& arguments)
|
|||
parser.setApplicationDescription(this->description);
|
||||
QCommandLineOption len(QStringList() << "L"
|
||||
<< "length",
|
||||
QObject::tr("Length of the generated password."),
|
||||
QObject::tr("Length of the generated password"),
|
||||
QObject::tr("length"));
|
||||
parser.addOption(len);
|
||||
QCommandLineOption lower(QStringList() << "l", QObject::tr("Use lowercase characters in the generated password."));
|
||||
QCommandLineOption lower(QStringList() << "l"
|
||||
<< "lower",
|
||||
QObject::tr("Use lowercase characters"));
|
||||
parser.addOption(lower);
|
||||
QCommandLineOption upper(QStringList() << "u", QObject::tr("Use uppercase characters in the generated password."));
|
||||
QCommandLineOption upper(QStringList() << "u"
|
||||
<< "upper",
|
||||
QObject::tr("Use uppercase characters"));
|
||||
parser.addOption(upper);
|
||||
QCommandLineOption numeric(QStringList() << "n", QObject::tr("Use numbers in the generated password."));
|
||||
QCommandLineOption numeric(QStringList() << "n"
|
||||
<< "numeric",
|
||||
QObject::tr("Use numbers."));
|
||||
parser.addOption(numeric);
|
||||
QCommandLineOption special(QStringList() << "s", QObject::tr("Use special characters in the generated password."));
|
||||
QCommandLineOption special(QStringList() << "s"
|
||||
<< "special",
|
||||
QObject::tr("Use special characters"));
|
||||
parser.addOption(special);
|
||||
QCommandLineOption extended(QStringList() << "e", QObject::tr("Use extended ASCII in the generated password."));
|
||||
QCommandLineOption extended(QStringList() << "e"
|
||||
<< "extended",
|
||||
QObject::tr("Use extended ASCII"));
|
||||
parser.addOption(extended);
|
||||
QCommandLineOption exclude(QStringList() << "x"
|
||||
<< "exclude",
|
||||
QObject::tr("Exclude character set"),
|
||||
QObject::tr("chars"));
|
||||
parser.addOption(exclude);
|
||||
QCommandLineOption exclude_similar(QStringList() << "exclude-similar",
|
||||
QObject::tr("Exclude similar looking characters"));
|
||||
parser.addOption(exclude_similar);
|
||||
QCommandLineOption every_group(QStringList() << "every-group",
|
||||
QObject::tr("Include characters from every selected group"));
|
||||
parser.addOption(every_group);
|
||||
|
||||
parser.process(arguments);
|
||||
|
||||
const QStringList args = parser.positionalArguments();
|
||||
|
@ -92,8 +114,18 @@ int Generate::execute(const QStringList& arguments)
|
|||
classes |= PasswordGenerator::EASCII;
|
||||
}
|
||||
|
||||
PasswordGenerator::GeneratorFlags flags = 0x0;
|
||||
|
||||
if (parser.isSet(exclude_similar)) {
|
||||
flags |= PasswordGenerator::ExcludeLookAlike;
|
||||
}
|
||||
if (parser.isSet(every_group)) {
|
||||
flags |= PasswordGenerator::CharFromEveryGroup;
|
||||
}
|
||||
|
||||
passwordGenerator.setCharClasses(classes);
|
||||
passwordGenerator.setFlags(PasswordGenerator::DefaultFlags);
|
||||
passwordGenerator.setFlags(flags);
|
||||
passwordGenerator.setExcludedChars(parser.value(exclude));
|
||||
|
||||
if (!passwordGenerator.isValid()) {
|
||||
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli generate");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue