mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-04 23:55:08 -04:00
Allow defining additional characters for the password generator
See issue #3271 for a motivation of this feature. This patch adds an additional text input to the advanced view of the password generator. All characters of this input field (if not empty) will be added as another group to the password generator. The characters from the excluded field have precedence over the characters from this new field, meaning any character added to both fields will *not* appear in any generated password. As the characters from this new field will be added as their own group to the password generator, checking the 'Include characters from every group' checkbox will force at least character to be chosen from the new input field. The `PasswordGenerator` class has also been changed so that the `isValid` method returns `true` if only characters from the new input field would be used. There is a new, simple test that covers the new feature. While the test only uses ASCII characters, any Unicode characters can be used with the new feature.
This commit is contained in:
parent
dce9af219f
commit
b2c2f42f30
8 changed files with 560 additions and 463 deletions
|
@ -29,6 +29,19 @@ void TestPasswordGenerator::initTestCase()
|
|||
QVERIFY(Crypto::init());
|
||||
}
|
||||
|
||||
void TestPasswordGenerator::testAdditionalChars()
|
||||
{
|
||||
PasswordGenerator generator;
|
||||
QVERIFY(!generator.isValid());
|
||||
generator.setAdditionalChars("aql");
|
||||
generator.setLength(2000);
|
||||
QVERIFY(generator.isValid());
|
||||
QString password = generator.generatePassword();
|
||||
QCOMPARE(password.size(), 2000);
|
||||
QRegularExpression regex(R"(^[aql]+$)");
|
||||
QVERIFY(regex.match(password).hasMatch());
|
||||
}
|
||||
|
||||
void TestPasswordGenerator::testCharClasses()
|
||||
{
|
||||
PasswordGenerator generator;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue