Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
duverleygrajales committed Feb 27, 2018
2 parents 5a90265 + 6b36c48 commit 72e5b6e
Show file tree
Hide file tree
Showing 8 changed files with 27,046 additions and 92 deletions.
2 changes: 1 addition & 1 deletion SEcubeWallet.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.3.1, 2018-02-25T10:18:40. -->
<!-- Written by QtCreator 4.3.1, 2018-02-26T23:58:24. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
204 changes: 156 additions & 48 deletions scr/addentry.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#include "addentry.h"
#include "ui_addentry.h"

#include "zxcvbn.h"

#include <QLineEdit>
#include <QString>
#include <QDebug>

#include <QAbstractButton>

#define OK_BUTTON 0
#define UNUSED(expr) (void)(expr)

Expand All @@ -10,10 +18,19 @@ AddEntry::AddEntry(QWidget *parent) :
ui(new Ui::AddEntry){

ui->setupUi(this);
ui->PassDoNot->setVisible(false);
ui->buttonBox->buttons()[0]->setEnabled(false); //Ok button initially disabled, as user has not entered any data
ui->InPass->setEnabled(true);
ui->InPass2->setEnabled(false);
ui->InPass->setEchoMode(QLineEdit::Password);
ui->InPass2->setEchoMode(QLineEdit::Password);
ui->sh_pass->setEnabled(false);
ui->score->setTextVisible(false);
ui->score->setValue(0);

setWindowTitle( tr("Fillout the new entry") );
setModal(true); //Modal, so user cannot access main window without first closing this one.
setModal(true); //Modal, so user cannot access main window without first closing this one

//connect(ui->InPass,SIGNAL(textChanged(QString)),this,SLOT(InPass_textChanged(QString)));
}

// Second constructor, called from eddit entry
Expand All @@ -28,8 +45,48 @@ AddEntry::AddEntry(QWidget *parent, QString EditUserIn, QString EditPassIn, QStr
ui->InPass->setText(EditPassIn);
ui->InPass2->setText(EditPassIn);

ui->PassDoNot->setVisible(false);
ui->buttonBox->buttons()[OK_BUTTON]->setEnabled(false);
if (!ZxcvbnInit()){
qDebug() << "Failed Open Dictionary File";
}else{
qDebug() << "Dictionary File Opened Correctly";
}
//----------------------

ui->InPass2->setEnabled(true);
ui->sh_pass->setEnabled(true);

const char* Line = EditPassIn.toLatin1().constData();
double e = ZxcvbnMatch(Line, NULL, 0);
//qDebug() << "Pass: " << text << " ; " << "Entropy: " << QString::number(e);

ui->entropy->setText(QString::number(e));

if(e <= 20.0){
ui->complex->setText("shortPass");
ui->complex2->setText("The password is too short");
ui->score->setValue(25);

}else if(e > 20.0 && e <= 30.0){
ui->complex->setText("badPass");
ui->complex2->setText("Weak; try combining letters & numbers");
ui->score->setValue(50);

}else if(e > 30.0 && e <= 40.0){
ui->complex->setText("goodPass");
ui->complex2->setText("Medium; try using special charecters");
ui->score->setValue(75);

}else if(e > 40.0){
ui->complex->setText("strongPass");
ui->complex2->setText("Strong password, good job!");
ui->score->setValue(100);
}

//----------------------
ZxcvbnUnInit();


ui->buttonBox->buttons()[OK_BUTTON]->setEnabled(true);
setWindowTitle( tr("Edit the entry") );
setModal(true);
}
Expand All @@ -50,62 +107,113 @@ QString AddEntry::getPassword(){
return ui->InPass->text();
}

// Each time the user modifies one of the text fields, we check if all of them have data, so we can enable Ok button
void AddEntry::EnableOkButton(){
bool ok = !ui->InDomain->text().isEmpty()
&& !ui->InUser->text().isEmpty()
&& !ui->InPass->text().isEmpty()
&& !ui->InPass2->text().isEmpty();

ui->buttonBox->buttons()[OK_BUTTON]->setEnabled(ok);
}

// If passwords are not equal, warning message
void AddEntry::PasswordWarning(){
if (ui->InPass->text() == ui->InPass2->text())
EqPass=true; // Flag, to allow ok button
else
EqPass=false;
ui->PassDoNot->setVisible(!EqPass);
}

// If the user wants to show the passwords, change EchoMode
void AddEntry::on_ShowPass_toggled(bool checked)
{
if (checked){
ui->InPass->setEchoMode(QLineEdit::Normal);
ui->InPass2->setEchoMode(QLineEdit::Normal);
}
else{
ui->InPass->setEchoMode(QLineEdit::Password);
ui->InPass2->setEchoMode(QLineEdit::Password);
}
}

void AddEntry::on_InUser_textChanged(const QString &arg1){
/*void AddEntry::on_InUser_textChanged(const QString &arg1){
EnableOkButton();
UNUSED(arg1);
}
}*/

void AddEntry::on_InDomain_textChanged(const QString &arg1){
/*void AddEntry::on_InDomain_textChanged(const QString &arg1){
EnableOkButton();
UNUSED(arg1);
}
}*/

void AddEntry::on_InPass_textChanged(const QString &arg1){
EnableOkButton();
void AddEntry::on_InPass_textChanged(QString text){
/*EnableOkButton();
PasswordWarning();
UNUSED(arg1);
UNUSED(arg1);*/

qDebug() << "perra";

if(!text.isEmpty()){
if (!ZxcvbnInit()){
qDebug() << "Failed Open Dictionary File";
}else{
qDebug() << "Dictionary File Opened Correctly";
}
//----------------------

ui->InPass2->setEnabled(true);
ui->sh_pass->setEnabled(true);

const char* Line = text.toLatin1().constData();
double e = ZxcvbnMatch(Line, NULL, 0);
//qDebug() << "Pass: " << text << " ; " << "Entropy: " << QString::number(e);

ui->entropy->setText(QString::number(e));

if(e <= 20.0){
ui->complex->setText("shortPass");
ui->complex2->setText("The password is too short");
ui->score->setValue(25);

}else if(e > 20.0 && e <= 30.0){
ui->complex->setText("badPass");
ui->complex2->setText("Weak; try combining letters & numbers");
ui->score->setValue(50);

}else if(e > 30.0 && e <= 40.0){
ui->complex->setText("goodPass");
ui->complex2->setText("Medium; try using special charecters");
ui->score->setValue(75);

}else if(e > 40.0){
ui->complex->setText("strongPass");
ui->complex2->setText("Strong password, good job!");
ui->score->setValue(100);
}

//----------------------
ZxcvbnUnInit();
}else{
ui->InPass2->setEnabled(false);
ui->sh_pass->setEnabled(false);
ui->score->setValue(0);
}
}

void AddEntry::on_InPass2_textChanged(const QString &arg1){
EnableOkButton();
void AddEntry::on_InPass2_textChanged(QString text){
/*EnableOkButton();
PasswordWarning();
UNUSED(arg1);
UNUSED(arg1);*/

if(!text.isEmpty()){
if(ui->InPass->text() == ui->InPass2->text()){
ui->match_pass->setText("The Passwords Match");
ui->buttonBox->buttons()[0]->setEnabled(true);
}else{
ui->match_pass->setText("The Passwords Do Not Match");
ui->buttonBox->buttons()[0]->setEnabled(false);
}

}else{
ui->match_pass->setText("");
ui->buttonBox->buttons()[0]->setEnabled(false);
}
}

void AddEntry::on_buttonBox_clicked(QAbstractButton* button){
if (EqPass)
void AddEntry::on_sh_pass_stateChanged(int value){
/*if (EqPass)
this->accept(); //Only emith accept() when passwords are equal
UNUSED(button);*/

if(value){
ui->InPass->setEchoMode(QLineEdit::Normal);
ui->InPass2->setEchoMode(QLineEdit::Normal);
}else{
ui->InPass->setEchoMode(QLineEdit::Password);
ui->InPass2->setEchoMode(QLineEdit::Password);
}
}

void AddEntry::on_buttonBox_clicked(QAbstractButton* button){
//if (EqPass)
//this->accept(); //Only emith accept() when passwords are equal
UNUSED(button);
//qDebug() << button;

if(!ui->InUser->text().isEmpty() && !ui->InDomain->text().isEmpty() && !ui->InPass->text().isEmpty() && !ui->InPass2->text().isEmpty()){
if(ui->InPass->text() == ui->InPass2->text()){
this->accept();
}
}
}
16 changes: 8 additions & 8 deletions scr/addentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ class AddEntry : public QDialog


private slots:
void on_InUser_textChanged(const QString &arg1);
void on_InDomain_textChanged(const QString &arg1);
void on_InPass_textChanged(const QString &arg1);
void on_InPass2_textChanged(const QString &arg1);
//void on_InUser_textChanged(QString arg1);
//void on_InDomain_textChanged(QString arg1);
void on_InPass_textChanged(QString text);
void on_InPass2_textChanged(QString text);
void on_sh_pass_stateChanged(int value);
void on_buttonBox_clicked(QAbstractButton *button);
void on_ShowPass_toggled(bool checked);

private:
Ui::AddEntry *ui;

void EnableOkButton();
void PasswordWarning();
//void EnableOkButton();
//void PasswordWarning();

bool EqPass;
//bool EqPass;
};

#endif // ADDENTRY_H
Loading

0 comments on commit 72e5b6e

Please sign in to comment.