mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 00:09:54 -05:00
Passphrase "MIXED case" Type (#11255)
* An additional approach to create passphrases with one random word being in UPPERCASE. * Also remove duplicate character count from passphrase generator --------- Co-authored-by: Stephan Heffner <stephan@heffner.it> Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
parent
9670a5e74e
commit
e76e9d42c7
@ -6902,10 +6902,6 @@ The following data is missing:
|
|||||||
<source>Word Count:</source>
|
<source>Word Count:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Character Count:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Word Case:</source>
|
<source>Word Case:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@ -6918,10 +6914,6 @@ The following data is missing:
|
|||||||
<source>Add custom wordlist</source>
|
<source>Add custom wordlist</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>character</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Close</source>
|
<source>Close</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@ -7035,6 +7027,10 @@ Do you want to overwrite it?</source>
|
|||||||
<source>Characters: %1</source>
|
<source>Characters: %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>MIXED case</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Excluded characters: "0", "1", "l", "I", "O", "|", "﹒", "B", "8", "G", "6"</source>
|
<source>Excluded characters: "0", "1", "l", "I", "O", "|", "﹒", "B", "8", "G", "6"</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
@ -122,6 +122,7 @@ QString PassphraseGenerator::generatePassphrase() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList words;
|
QStringList words;
|
||||||
|
int randomIndex = randomGen()->randomUInt(static_cast<quint32>(m_wordCount));
|
||||||
for (int i = 0; i < m_wordCount; ++i) {
|
for (int i = 0; i < m_wordCount; ++i) {
|
||||||
int wordIndex = randomGen()->randomUInt(static_cast<quint32>(m_wordlist.size()));
|
int wordIndex = randomGen()->randomUInt(static_cast<quint32>(m_wordlist.size()));
|
||||||
auto tmpWord = m_wordlist.at(wordIndex);
|
auto tmpWord = m_wordlist.at(wordIndex);
|
||||||
@ -134,6 +135,9 @@ QString PassphraseGenerator::generatePassphrase() const
|
|||||||
case TITLECASE:
|
case TITLECASE:
|
||||||
tmpWord = tmpWord.replace(0, 1, tmpWord.left(1).toUpper());
|
tmpWord = tmpWord.replace(0, 1, tmpWord.left(1).toUpper());
|
||||||
break;
|
break;
|
||||||
|
case MIXEDCASE:
|
||||||
|
tmpWord = i == randomIndex ? tmpWord.toUpper() : tmpWord.toLower();
|
||||||
|
break;
|
||||||
case LOWERCASE:
|
case LOWERCASE:
|
||||||
tmpWord = tmpWord.toLower();
|
tmpWord = tmpWord.toLower();
|
||||||
break;
|
break;
|
||||||
|
@ -30,7 +30,8 @@ public:
|
|||||||
{
|
{
|
||||||
LOWERCASE,
|
LOWERCASE,
|
||||||
UPPERCASE,
|
UPPERCASE,
|
||||||
TITLECASE
|
TITLECASE,
|
||||||
|
MIXEDCASE
|
||||||
};
|
};
|
||||||
|
|
||||||
double estimateEntropy(int wordCount = 0);
|
double estimateEntropy(int wordCount = 0);
|
||||||
|
@ -99,6 +99,7 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
|
|||||||
m_ui->wordCaseComboBox->addItem(tr("lower case"), PassphraseGenerator::LOWERCASE);
|
m_ui->wordCaseComboBox->addItem(tr("lower case"), PassphraseGenerator::LOWERCASE);
|
||||||
m_ui->wordCaseComboBox->addItem(tr("UPPER CASE"), PassphraseGenerator::UPPERCASE);
|
m_ui->wordCaseComboBox->addItem(tr("UPPER CASE"), PassphraseGenerator::UPPERCASE);
|
||||||
m_ui->wordCaseComboBox->addItem(tr("Title Case"), PassphraseGenerator::TITLECASE);
|
m_ui->wordCaseComboBox->addItem(tr("Title Case"), PassphraseGenerator::TITLECASE);
|
||||||
|
m_ui->wordCaseComboBox->addItem(tr("MIXED case"), PassphraseGenerator::MIXEDCASE);
|
||||||
|
|
||||||
// load system-wide wordlists
|
// load system-wide wordlists
|
||||||
QDir path(resources()->wordlistPath(""));
|
QDir path(resources()->wordlistPath(""));
|
||||||
@ -276,7 +277,6 @@ void PasswordGeneratorWidget::updatePasswordStrength()
|
|||||||
PasswordHealth passwordHealth(0);
|
PasswordHealth passwordHealth(0);
|
||||||
if (m_ui->tabWidget->currentIndex() == Diceware) {
|
if (m_ui->tabWidget->currentIndex() == Diceware) {
|
||||||
passwordHealth.init(m_dicewareGenerator->estimateEntropy());
|
passwordHealth.init(m_dicewareGenerator->estimateEntropy());
|
||||||
m_ui->charactersInPassphraseLabel->setText(QString::number(m_ui->editNewPassword->text().length()));
|
|
||||||
} else {
|
} else {
|
||||||
passwordHealth = PasswordHealth(m_ui->editNewPassword->text());
|
passwordHealth = PasswordHealth(m_ui->editNewPassword->text());
|
||||||
}
|
}
|
||||||
|
@ -769,26 +769,6 @@ QProgressBar::chunk {
|
|||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="2" column="1" alignment="Qt::AlignRight">
|
|
||||||
<widget class="QLabel" name="labelWordSeparator">
|
|
||||||
<property name="text">
|
|
||||||
<string>Word Separator:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" alignment="Qt::AlignRight">
|
|
||||||
<widget class="QLabel" name="labelWordList">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Wordlist:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
@ -834,23 +814,6 @@ QProgressBar::chunk {
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" alignment="Qt::AlignRight">
|
|
||||||
<widget class="QLabel" name="labelWordCount">
|
|
||||||
<property name="text">
|
|
||||||
<string>Word Count:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>spinBoxLength</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1" alignment="Qt::AlignRight">
|
|
||||||
<widget class="QLabel" name="characterCountLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Character Count:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1" alignment="Qt::AlignRight">
|
<item row="3" column="1" alignment="Qt::AlignRight">
|
||||||
<widget class="QLabel" name="wordCaseLabel">
|
<widget class="QLabel" name="wordCaseLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -858,62 +821,13 @@ QProgressBar::chunk {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="2" column="1" alignment="Qt::AlignRight">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<widget class="QLabel" name="labelWordSeparator">
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="wordCaseComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_4">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="editWordSeparator">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>Word Separator:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_7">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||||
<item>
|
<item>
|
||||||
@ -954,10 +868,82 @@ QProgressBar::chunk {
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="2" alignment="Qt::AlignLeft">
|
<item row="3" column="2">
|
||||||
<widget class="QLabel" name="charactersInPassphraseLabel">
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="wordCaseComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" alignment="Qt::AlignRight">
|
||||||
|
<widget class="QLabel" name="labelWordCount">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>character</string>
|
<string>Word Count:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>spinBoxLength</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="editWordSeparator">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_7">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" alignment="Qt::AlignRight">
|
||||||
|
<widget class="QLabel" name="labelWordList">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Wordlist:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -1027,11 +1027,12 @@ void TestGui::testDicewareEntryEntropy()
|
|||||||
// Verify entropy and strength
|
// Verify entropy and strength
|
||||||
auto* entropyLabel = pwGeneratorWidget->findChild<QLabel*>("entropyLabel");
|
auto* entropyLabel = pwGeneratorWidget->findChild<QLabel*>("entropyLabel");
|
||||||
auto* strengthLabel = pwGeneratorWidget->findChild<QLabel*>("strengthLabel");
|
auto* strengthLabel = pwGeneratorWidget->findChild<QLabel*>("strengthLabel");
|
||||||
auto* wordLengthLabel = pwGeneratorWidget->findChild<QLabel*>("charactersInPassphraseLabel");
|
auto* wordLengthLabel = pwGeneratorWidget->findChild<QLabel*>("passwordLengthLabel");
|
||||||
|
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(entropyLabel->text(), QString("Entropy: 77.55 bit"), 200);
|
QTRY_COMPARE_WITH_TIMEOUT(entropyLabel->text(), QString("Entropy: 77.55 bit"), 200);
|
||||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Good"));
|
QCOMPARE(strengthLabel->text(), QString("Password Quality: Good"));
|
||||||
QCOMPARE(wordLengthLabel->text().toInt(), pwGeneratorWidget->getGeneratedPassword().size());
|
QCOMPARE(wordLengthLabel->text(),
|
||||||
|
QString("Characters: %1").arg(QString::number(pwGeneratorWidget->getGeneratedPassword().length())));
|
||||||
|
|
||||||
QTest::mouseClick(generatedPassword, Qt::LeftButton);
|
QTest::mouseClick(generatedPassword, Qt::LeftButton);
|
||||||
QTest::keyClick(generatedPassword, Qt::Key_Escape););
|
QTest::keyClick(generatedPassword, Qt::Key_Escape););
|
||||||
|
Loading…
Reference in New Issue
Block a user