let every string as separator

This commit is contained in:
thez3ro 2017-03-17 01:43:50 +01:00
parent 7541f57aeb
commit 8937647d5f
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
4 changed files with 12 additions and 14 deletions

View File

@ -75,7 +75,7 @@ void PassphraseGenerator::setWordlist(QString path)
} }
} }
void PassphraseGenerator::setWordseparator(QChar separator) { void PassphraseGenerator::setWordseparator(QString separator) {
m_separator = separator; m_separator = separator;
} }

View File

@ -30,14 +30,14 @@ public:
double calculateEntropy(QString passphrase); double calculateEntropy(QString passphrase);
void setWordCount(int wordCount); void setWordCount(int wordCount);
void setWordlist(QString path); void setWordlist(QString path);
void setWordseparator(QChar separator); void setWordseparator(QString separator);
bool isValid() const; bool isValid() const;
QString generatePassphrase() const; QString generatePassphrase() const;
private: private:
int m_wordCount; int m_wordCount;
QChar m_separator; QString m_separator;
QVector<QString> m_wordlist; QVector<QString> m_wordlist;
Q_DISABLE_COPY(PassphraseGenerator) Q_DISABLE_COPY(PassphraseGenerator)

View File

@ -48,7 +48,7 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
connect(m_ui->sliderWordCount, SIGNAL(valueChanged(int)), SLOT(dicewareSliderMoved())); connect(m_ui->sliderWordCount, SIGNAL(valueChanged(int)), SLOT(dicewareSliderMoved()));
connect(m_ui->spinBoxWordCount, SIGNAL(valueChanged(int)), SLOT(dicewareSpinBoxChanged())); connect(m_ui->spinBoxWordCount, SIGNAL(valueChanged(int)), SLOT(dicewareSpinBoxChanged()));
connect(m_ui->comboBoxWordSeparator, SIGNAL(currentIndexChanged(int)), SLOT(updateGenerator())); connect(m_ui->editWordSeparator, SIGNAL(textChanged(QString)), SLOT(updateGenerator()));
connect(m_ui->comboBoxWordList, SIGNAL(currentIndexChanged(int)), SLOT(updateGenerator())); connect(m_ui->comboBoxWordList, SIGNAL(currentIndexChanged(int)), SLOT(updateGenerator()));
connect(m_ui->optionButtons, SIGNAL(buttonClicked(int)), SLOT(updateGenerator())); connect(m_ui->optionButtons, SIGNAL(buttonClicked(int)), SLOT(updateGenerator()));
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(updateGenerator())); connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(updateGenerator()));
@ -63,7 +63,8 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
m_ui->strengthLabel->setFont(defaultFont); m_ui->strengthLabel->setFont(defaultFont);
} }
m_ui->comboBoxWordSeparator->addItems(QStringList() << " " << "#" << "_" << ";" << "-" << ":" << "." << "@"); // set default separator to Space
m_ui->editWordSeparator->setText(" ");
QDir path(filePath()->dataPath("wordlists/")); QDir path(filePath()->dataPath("wordlists/"));
QStringList files = path.entryList(QDir::Files); QStringList files = path.entryList(QDir::Files);
@ -97,7 +98,7 @@ void PasswordGeneratorWidget::loadSettings()
// Diceware config // Diceware config
m_ui->spinBoxWordCount->setValue(config()->get("generator/WordCount", 6).toInt()); m_ui->spinBoxWordCount->setValue(config()->get("generator/WordCount", 6).toInt());
m_ui->comboBoxWordSeparator->setCurrentIndex(config()->get("generator/WordSeparator", 0).toInt()); m_ui->editWordSeparator->setText(config()->get("generator/WordSeparator", " ").toString());
m_ui->comboBoxWordList->setCurrentText(config()->get("generator/WordList", "eff_large.wordlist").toString()); m_ui->comboBoxWordList->setCurrentText(config()->get("generator/WordList", "eff_large.wordlist").toString());
// Password or diceware? // Password or diceware?
@ -117,7 +118,7 @@ void PasswordGeneratorWidget::saveSettings()
// Diceware config // Diceware config
config()->set("generator/WordCount", m_ui->spinBoxWordCount->value()); config()->set("generator/WordCount", m_ui->spinBoxWordCount->value());
config()->set("generator/WordSeparator", m_ui->comboBoxWordSeparator->currentIndex()); config()->set("generator/WordSeparator", m_ui->editWordSeparator->text());
config()->set("generator/WordList", m_ui->comboBoxWordList->currentText()); config()->set("generator/WordList", m_ui->comboBoxWordList->currentText());
// Password or diceware? // Password or diceware?
@ -364,7 +365,7 @@ void PasswordGeneratorWidget::updateGenerator()
QString path = filePath()->dataPath("wordlists/" + m_ui->comboBoxWordList->currentText()); QString path = filePath()->dataPath("wordlists/" + m_ui->comboBoxWordList->currentText());
m_dicewareGenerator->setWordlist(path); m_dicewareGenerator->setWordlist(path);
} }
m_dicewareGenerator->setWordseparator(m_ui->comboBoxWordSeparator->currentText().at(0)); m_dicewareGenerator->setWordseparator(m_ui->editWordSeparator->text());
if (m_dicewareGenerator->isValid()) { if (m_dicewareGenerator->isValid()) {
m_ui->buttonGenerate->setEnabled(true); m_ui->buttonGenerate->setEnabled(true);

View File

@ -537,12 +537,9 @@ QProgressBar::chunk {
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QComboBox" name="comboBoxWordSeparator"> <widget class="QLineEdit" name="editWordSeparator">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <string> </string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>