Accueil > > > GENERATEUR DE MOT DE PASSE AVEC INTERFACE QT 4.4.3
GENERATEUR DE MOT DE PASSE AVEC INTERFACE QT 4.4.3
Information sur la source
Description
voici l'amélioration de mon générateur de mot de passe que j'avais posté et codé en c++ (console) j'ai créer l'interface avec qt et j'ai apporter quelques améliorations au code de départ vous pouvez créer des mots de passe avec des majuscules, des minuscules, des chiffre, des caractères spéciaux. vous pouvez également créer un mot de passe en utilisant votre nom et prénom.
Source
- FenCodeGenere.h:
-
- #ifndef HEADER_FENCODEGENERE
- #define HEADER_FENCODEGENERE
-
- #include <QtGui>
-
- class FenCodeGenere : public QDialog
- {
- public:
- FenCodeGenere(QString &code, QWidget *parent);
-
- private:
- QLabel *proposition;
- QTextEdit *codeGenere;
- QPushButton *fermer;
- };
-
-
- #endif
-
- FenGenereCode.cpp :
-
- #include "FenCodeGenere.h"
-
- FenCodeGenere::FenCodeGenere(QString &code, QWidget *parent = 0) : QDialog(parent)
- {
- proposition = new QLabel("Proposition de MDP : \n~~~~~~~~~~~~");
- proposition->setFont(QFont("digital",12));
- codeGenere = new QTextEdit();
- codeGenere->setStyleSheet("background-color: rgb(236, 201, 248)");
- codeGenere->setPlainText(code);
- codeGenere->setReadOnly(true);
- codeGenere->setFont(QFont("Courier", 16, QFont::Bold));
- codeGenere->setLineWrapMode(QTextEdit::NoWrap);
-
-
- fermer = new QPushButton("Fermer");
- fermer->setFont(QFont("digital", 12, QFont::Bold));
- fermer->setStyleSheet("background-color: rgb(236, 201, 248)");
-
- QVBoxLayout *layoutPrincipal = new QVBoxLayout;
- layoutPrincipal->addWidget(proposition);
- layoutPrincipal->addWidget(codeGenere);
- layoutPrincipal->addWidget(fermer);
-
- resize(700, 450);
- setLayout(layoutPrincipal);
-
- connect(fermer, SIGNAL(clicked()), this, SLOT(accept()));
- }
-
-
- fenetre.h:
-
- #ifndef HEADER_FENETRE
- #define HEADER_FENETRE
-
- #include <QtGui>
-
- class Fenetre : public QWidget
- {
- Q_OBJECT
-
- public:
- Fenetre();
-
- public slots:
- void ouvrirAbout();
- void genererCode();
- void personnaliser();
- void Aide();
-
- private:
- QFormLayout *layoutNom;
- QLineEdit *nom, *prenom;
- QLabel *label, *nbCaract, *space, *space2;
- QRadioButton *min, *maj, *num, *spe, *mix, *utilis, *utilis_2;
- QPushButton *generer, *m_quitter, *m_about, *perso, *aide;
- QVBoxLayout *layoutChoix, *layoutLabel, *layoutCaractere, *layoutPrincipal;
- QHBoxLayout *layoutGenerer, *boutonsLayout, *layoutSpace, *layoutSpace2;
- QGroupBox *box, *boxCaractere, *utilisateur;
-
- };
-
- #endif
-
- fenetre.cpp :
-
- #include <iostream>
- #include <ctime>
-
- #include "Fenetre.h"
- #include "FenCodeGenere.h"
-
- using namespace std;
- int loop=0;
- QString code;
-
- Fenetre::Fenetre() : QWidget()
- {
- setWindowIcon(QIcon("prog.bmp"));
- setWindowTitle("MDP Générator");
- setFont(QFont("digital", 12));
- setStyleSheet("background-color: rgb(192,186,252)");//236,201,248 ou 247,228,252
-
-
- //layout principal
- layoutPrincipal = new QVBoxLayout;
-
- layoutNom = new QFormLayout;
- nom = new QLineEdit;
- nom->setStyleSheet("background-color: rgb(236, 201, 248)");
- nom->setFont(QFont("Digital", 12));
- prenom = new QLineEdit;
- prenom->setStyleSheet("background-color: rgb(236, 201, 248)");
- prenom->setFont(QFont("Digital", 12));
- layoutNom->addRow("&Nom :", nom);
- layoutNom->addRow("&Prenom :", prenom);
- utilisateur = new QGroupBox("&Utilisateur :");
- utilisateur->setLayout(layoutNom);
-
- //1er layout : presentation du produit
- label = new QLabel("<strong>Générateur de mot de passe</strong> !<br />Codé par <strong>Micmic</strong> !<br />Version 2.0", this);
- label->setAlignment(Qt::AlignCenter);
-
- //2eme layout : choix
- box = new QGroupBox("Que voulez-vous &utiliser ?");
-
- //sous layout : radiobutton
- layoutChoix = new QVBoxLayout;
-
- utilis = new QRadioButton("mot de passe avec des lettres de votre nom, prénom et des caractères spéc&iaux");
- utilis_2 = new QRadioButton("mot de passe avec 3 lettres de votre nom, de votre prénom et un nombre");
- maj = new QRadioButton("mot de passe n'utilisant que des &majuscules");
- min = new QRadioButton("mot de passe n'utilisant que des m&inuscules");
- num = new QRadioButton("mot de passe n'utilisant que des &chiffres");
- spe = new QRadioButton("mot de passe n'utilisant que des caractères &spéciaux");
- mix = new QRadioButton("m&ot de passe utilisant des majuscules, minuscules, des chiffres\net des caractères spéciaux");
-
- utilis->setChecked(true);
-
- layoutChoix -> addWidget(utilis);
- layoutChoix -> addWidget(utilis_2);
- layoutChoix -> addWidget(maj);
- layoutChoix -> addWidget(min);
- layoutChoix -> addWidget(num);
- layoutChoix -> addWidget(spe);
- layoutChoix -> addWidget(mix);
-
- box->setLayout(layoutChoix);
-
- layoutLabel = new QVBoxLayout;
-
- nbCaract = new QLabel("<strong><br />Le programme va générer des mots de passe <br />"
- "de la longueur que vous préciserez ci dessous</strong><br />", this);
- layoutLabel->addWidget(nbCaract);
- nbCaract->setAlignment(Qt::AlignCenter);
-
- boxCaractere = new QGroupBox("Nombe de caractères pour votre mot de passe :");//contenant spinbox et Qlabel
- layoutCaractere = new QVBoxLayout; // layout contenant la spinbox
-
- perso = new QPushButton("&Personnaliser le nombre de caractères");
- perso->setToolTip("choisir le nombre de caractère pour le mot de passe");
- perso->setFont(QFont("digital", 12));
- perso->setStyleSheet("background-color: rgb(236, 201, 248)");
-
- layoutCaractere->addSpacing(10);
- layoutCaractere->addWidget(perso);
-
- boxCaractere->setLayout(layoutCaractere);
-
- layoutSpace = new QHBoxLayout;
- space = new QLabel("Le programme va vous proposer 10 mots de passe differents<br />");
- space->setAlignment(Qt::AlignCenter);
- layoutSpace ->addWidget(space);
-
- layoutGenerer = new QHBoxLayout;
- generer = new QPushButton ("&GENERER");
- generer->setFont(QFont("digital", 16));
- generer->setStyleSheet("background-color: rgb(236, 201, 248)");
- generer->setCursor(Qt::PointingHandCursor);
- generer->setToolTip("générer le mot de passe");
- layoutGenerer->addWidget(generer);
-
- layoutSpace2 = new QHBoxLayout;
- space2 = new QLabel("<br />");
- layoutSpace2->addWidget(space2);
-
- boutonsLayout = new QHBoxLayout;
-
- m_about = new QPushButton ("A &Propos");
- m_about->setToolTip("à propos");
- m_about->setFont(QFont("digital", 14));
- m_about->setStyleSheet("background-color: rgb(236, 201, 248)");
-
- aide = new QPushButton("&Aide");
- aide->setToolTip("aide");
- aide->setFont(QFont("digital", 14));
- aide->setStyleSheet("background-color: rgb(236, 201, 248)");
-
- m_quitter = new QPushButton( "&Quitter");
- m_quitter->setToolTip("Quitter");
- m_quitter->setFont(QFont("digital", 14));
- m_quitter->setStyleSheet("background-color: rgb(236, 201, 248)");
-
- boutonsLayout->addWidget(m_about);
- boutonsLayout->addWidget(aide);
- boutonsLayout->addWidget(m_quitter);
-
- layoutPrincipal->addWidget(label);
- layoutPrincipal->addWidget(utilisateur);
- layoutPrincipal->addWidget(box);
- layoutPrincipal->addWidget(nbCaract);
- layoutPrincipal->addWidget(boxCaractere);
- layoutPrincipal->addLayout(layoutSpace);
- layoutPrincipal->addLayout(layoutGenerer);
- layoutPrincipal->addLayout(layoutSpace2);
- layoutPrincipal->addLayout(boutonsLayout);
-
- setLayout(layoutPrincipal);
-
- QObject::connect(m_quitter, SIGNAL(clicked()), qApp, SLOT(quit()));
- QObject::connect(m_about, SIGNAL(clicked()), this, SLOT(ouvrirAbout()));
- QObject::connect(aide, SIGNAL(clicked()), this, SLOT(Aide()));
- QObject::connect(generer, SIGNAL(clicked()), this, SLOT(genererCode()));
- QObject::connect(perso, SIGNAL(clicked()), this, SLOT(personnaliser()));
-
- }
-
- void Fenetre::ouvrirAbout()
- {
-
- QMessageBox::about(this,"MDP Générator", "Merci d'utiliser <strong>MDP Générator</strong>"
- "<br /><br />MDP Générator est un Générateur de mot de passe, "
- "<br />Développé par Micmic : codé en c++ avec une interface produite avec Qt"
- "<br />Version 2.0, codé le 12 Janvier 2009 !"
- "<br /><br />vous pouvez générer des mots de passe, des clés WEP, WAP, de cryptage,etc.... ");
- setFont(QFont("digital", 12));
- }
-
-
- void Fenetre::genererCode()
- {
- srand(time(NULL));
- //QString code;
- if(nom->text().isEmpty() || prenom->text().isEmpty())
- {
- QMessageBox::critical(this, "Erreur", "Veuillez entrer un nom et un prénom");
- return;
- }
-
- if(loop ==0)
- {
- QMessageBox::critical(this,"MDP Générator", "vous devez d'abord choisir le nombre de caractères");
- return;
- }
-
- else
- {
- if(utilis ->isChecked())
- {
- const char spe[] = {'&', '~', '#', 'ç', '@', '£', '$', '%', 'µ', '§'}; // max = 9
- int MAX =9, MIN=1;
-
- QString str_nom = nom->text();
- int n_max = str_nom.size();
- QString str_prenom = prenom->text();
- int p_max = str_prenom.size();
-
- if (loop ==3)
- {
- for (int i=0; i < 10; i++)
- {
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code +="\n";
- }
- }
- else if(loop == 4)
- {
- for (int i=0; i < 10; i++)
- {
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
- code +="\n";
- }
- }
- else if (loop == 5)
- {
- for (int i=0; i < 10; i++)
- {
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
- code +="\n";
- }
- }
- else if (loop == 6)
- {
- for (int i=0; i < 10; i++)
- {
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
- code +="\n";
- }
- }
- else if (loop == 7)
- {
- for (int i=0; i < 10; i++)
- {
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
- code +="\n";
- }
- }
- else if (loop == 8)
- {
- for (int i=0; i < 10; i++)
- {
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
- code +="\n";
- }
- }
- else if (loop == 9)
- {
- for (int i=0; i < 10; i++)
- {
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
- code +="\n";
- }
- }
- else if (loop == 10)
- {
- for (int i=0; i < 10; i++)
- {
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
- code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
- code +=" ";
- code +="\n";
- }
- }
-
- }
- else if (utilis_2 -> isChecked())
- {
- QString str2_nom = nom->text();
- QString str2_prenom = prenom->text();
- int min_num =1900, max_num = 2010;
- int n_max =10, n_min =0;
- int hasard = ((rand () % (n_max - n_min +1)) - n_min);
- if ((hasard%2)==0)
- {
- for (int i=0; i < 10; i++)
- {
-
- code += str2_nom[0];
- code += str2_nom[1];
- code += str2_nom[2];
- code += "_";
- code += str2_prenom[0];
- code += str2_prenom[1];
- code += str2_prenom[2];
- code += QString ::number (int((rand() % (max_num - min_num +1)) + min_num), 10);
- code +=" ";
- code += "\n";
- }
- code += "\n";
- }
- else
- {
- for (int i=0; i < 10; i++)
- {
-
- code += str2_prenom[0];
- code += str2_prenom[1];
- code += str2_prenom[2];
- code += "_";
- code += str2_nom[0];
- code += str2_nom[1];
- code += str2_nom[2];
- code += QString ::number (int((rand() % (max_num - min_num +1)) + min_num), 10);
- code +=" ";
- code += "\n";
- }
- code += "\n";
- }
-
- }
-
- else if (maj ->isChecked())
- {
- int MAX = 25, MIN =1;
- const char maj[] = {'A', 'B', 'C', 'D','E', 'F', 'G', 'H', 'I', 'J', // max = 25
- 'K', 'L', 'M', 'N','O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z'};
-
- for (int j=0; j<10; j++)
- {
- code+="\t";
- for (int i=0; i < loop; i++)
- {
- code += maj[(rand() % (MAX - MIN + 1)) + MIN];
- code += " ";
- }
- code += "\n";
- }
- }
- else if (min->isChecked())
- {
- int MAX = 25, MIN =1;
- const char min[] = {'a','b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', // max = 25
- 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
- 'u', 'v', 'w', 'x', 'y', 'z'};
- for (int j=0; j<10; j++)
- {
- code+="\t";
- for (int i=0; i < loop; i++)
- {
- code += min[(rand() % (MAX - MIN + 1)) + MIN];
- code += " ";
- }
- code += "\n";
- }
- }
- else if(num->isChecked())
- {
- int MAX = 9, MIN =1;
- const char num[] = {'0', '1', '2', '3','4', '5', '6', '7', '8', '9'}; // max = 9
-
- for (int j=0; j<10; j++)
- {
- code+="\t";
- for (int i=0; i < loop; i++)
- {
- code += num[(rand() % (MAX - MIN + 1)) + MIN];
- code += " ";
- }
- code += "\n";
- }
- }
- else if(spe->isChecked())
- {
- int MAX = 9, MIN =1;
- const char spe[] = {'&', '~', '#', 'ç', '@', '£', '$', '%', 'µ', '§'}; // max = 9
-
- for (int j=0; j<10; j++)
- {
- code+="\t";
- for (int i=0; i < loop; i++)
- {
- code += spe[(rand() % (MAX - MIN + 1)) + MIN];
- code += " ";
- }
- code += "\n";
- }
- }
- else if(mix->isChecked())
- {
- int MAX = 70, MIN =1;
- const char mix[] = {'a','b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', // max = 70
- 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
- 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D',
- 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
- 'O', 'P', 'Q', 'R', 'S', 'T','U', 'V', 'W', 'X',
- 'Y', 'Z', '0', '1', '2', '3','4', '5', '6', '7',
- '8', '9', '&', '~', '#', 'ç', '@', '£', '$', '%',
- 'µ', '§'};
- for (int j=0; j<10; j++)
- {
- code+="\t";
- for (int i=0; i < loop; i++)
- {
- code += mix[(rand() % (MAX - MIN + 1)) + MIN];
- code += " ";
- }
- code += "\n";
- }
- }
-
-
- FenCodeGenere *fenetreCode = new FenCodeGenere(code, this);
- fenetreCode->exec();
- }
- }
-
- void Fenetre::personnaliser()
- {
- if (utilis->isChecked())
- {
- bool ok;
- int i = QInputDialog::getInteger(this, tr("Personnaliser le mot de passe"),
- tr("nombre de caracteres:"), 1, 3, 10, 1, &ok);
- loop = i;
- }
- else if (utilis_2->isChecked())
- {
- bool ok;
- int i = QInputDialog::getInteger(this, tr("Personnaliser le mot de passe"),
- tr("nombre de caracteres fixé à:"), 1, 10, 10, 1, &ok);
- loop = i;
- }
- else if( maj->isChecked() || min->isChecked() || num->isChecked() || spe->isChecked() || mix->isChecked())
- {
- bool ok;
- int i = QInputDialog::getInteger(this, tr("Personnaliser le mot de passe"),
- tr("nombre de caracteres:"), 1, 1, 50, 1, &ok);
- loop = i;
- }
- }
-
- void Fenetre::Aide()
- {
- QMessageBox::about(this,"MDP Générator", "Merci d'utiliser <strong>MDP Générator</strong>"
- "<br /><br />1- Vous devez cocher une case pour choisir les caracteres désirés"
- "<br />2- Cliquer sur \"Personnaliser le nombre de caracteres\""
- "<br />3- choisir le nombre dans la fenetre ouverte en cliquant sur les fleches haut et bas"
- "<br />4- Cliquer sur générer pour decouvrir les propositions de mot de passe");
-
- }
-
- main.cpp :
-
- #include <QApplication>
- #include "Fenetre.h"
-
- int main(int argc, char* argv[])
- {
- QApplication app(argc, argv);
-
- QString locale = QLocale::system().name();
- QTranslator translator;
- translator.load(QString("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
- app.installTranslator(&translator);
-
-
- Fenetre fenetre;
- fenetre.show();
-
- return app.exec();
- }
FenCodeGenere.h:
#ifndef HEADER_FENCODEGENERE
#define HEADER_FENCODEGENERE
#include <QtGui>
class FenCodeGenere : public QDialog
{
public:
FenCodeGenere(QString &code, QWidget *parent);
private:
QLabel *proposition;
QTextEdit *codeGenere;
QPushButton *fermer;
};
#endif
FenGenereCode.cpp :
#include "FenCodeGenere.h"
FenCodeGenere::FenCodeGenere(QString &code, QWidget *parent = 0) : QDialog(parent)
{
proposition = new QLabel("Proposition de MDP : \n~~~~~~~~~~~~");
proposition->setFont(QFont("digital",12));
codeGenere = new QTextEdit();
codeGenere->setStyleSheet("background-color: rgb(236, 201, 248)");
codeGenere->setPlainText(code);
codeGenere->setReadOnly(true);
codeGenere->setFont(QFont("Courier", 16, QFont::Bold));
codeGenere->setLineWrapMode(QTextEdit::NoWrap);
fermer = new QPushButton("Fermer");
fermer->setFont(QFont("digital", 12, QFont::Bold));
fermer->setStyleSheet("background-color: rgb(236, 201, 248)");
QVBoxLayout *layoutPrincipal = new QVBoxLayout;
layoutPrincipal->addWidget(proposition);
layoutPrincipal->addWidget(codeGenere);
layoutPrincipal->addWidget(fermer);
resize(700, 450);
setLayout(layoutPrincipal);
connect(fermer, SIGNAL(clicked()), this, SLOT(accept()));
}
fenetre.h:
#ifndef HEADER_FENETRE
#define HEADER_FENETRE
#include <QtGui>
class Fenetre : public QWidget
{
Q_OBJECT
public:
Fenetre();
public slots:
void ouvrirAbout();
void genererCode();
void personnaliser();
void Aide();
private:
QFormLayout *layoutNom;
QLineEdit *nom, *prenom;
QLabel *label, *nbCaract, *space, *space2;
QRadioButton *min, *maj, *num, *spe, *mix, *utilis, *utilis_2;
QPushButton *generer, *m_quitter, *m_about, *perso, *aide;
QVBoxLayout *layoutChoix, *layoutLabel, *layoutCaractere, *layoutPrincipal;
QHBoxLayout *layoutGenerer, *boutonsLayout, *layoutSpace, *layoutSpace2;
QGroupBox *box, *boxCaractere, *utilisateur;
};
#endif
fenetre.cpp :
#include <iostream>
#include <ctime>
#include "Fenetre.h"
#include "FenCodeGenere.h"
using namespace std;
int loop=0;
QString code;
Fenetre::Fenetre() : QWidget()
{
setWindowIcon(QIcon("prog.bmp"));
setWindowTitle("MDP Générator");
setFont(QFont("digital", 12));
setStyleSheet("background-color: rgb(192,186,252)");//236,201,248 ou 247,228,252
//layout principal
layoutPrincipal = new QVBoxLayout;
layoutNom = new QFormLayout;
nom = new QLineEdit;
nom->setStyleSheet("background-color: rgb(236, 201, 248)");
nom->setFont(QFont("Digital", 12));
prenom = new QLineEdit;
prenom->setStyleSheet("background-color: rgb(236, 201, 248)");
prenom->setFont(QFont("Digital", 12));
layoutNom->addRow("&Nom :", nom);
layoutNom->addRow("&Prenom :", prenom);
utilisateur = new QGroupBox("&Utilisateur :");
utilisateur->setLayout(layoutNom);
//1er layout : presentation du produit
label = new QLabel("<strong>Générateur de mot de passe</strong> !<br />Codé par <strong>Micmic</strong> !<br />Version 2.0", this);
label->setAlignment(Qt::AlignCenter);
//2eme layout : choix
box = new QGroupBox("Que voulez-vous &utiliser ?");
//sous layout : radiobutton
layoutChoix = new QVBoxLayout;
utilis = new QRadioButton("mot de passe avec des lettres de votre nom, prénom et des caractères spéc&iaux");
utilis_2 = new QRadioButton("mot de passe avec 3 lettres de votre nom, de votre prénom et un nombre");
maj = new QRadioButton("mot de passe n'utilisant que des &majuscules");
min = new QRadioButton("mot de passe n'utilisant que des m&inuscules");
num = new QRadioButton("mot de passe n'utilisant que des &chiffres");
spe = new QRadioButton("mot de passe n'utilisant que des caractères &spéciaux");
mix = new QRadioButton("m&ot de passe utilisant des majuscules, minuscules, des chiffres\net des caractères spéciaux");
utilis->setChecked(true);
layoutChoix -> addWidget(utilis);
layoutChoix -> addWidget(utilis_2);
layoutChoix -> addWidget(maj);
layoutChoix -> addWidget(min);
layoutChoix -> addWidget(num);
layoutChoix -> addWidget(spe);
layoutChoix -> addWidget(mix);
box->setLayout(layoutChoix);
layoutLabel = new QVBoxLayout;
nbCaract = new QLabel("<strong><br />Le programme va générer des mots de passe <br />"
"de la longueur que vous préciserez ci dessous</strong><br />", this);
layoutLabel->addWidget(nbCaract);
nbCaract->setAlignment(Qt::AlignCenter);
boxCaractere = new QGroupBox("Nombe de caractères pour votre mot de passe :");//contenant spinbox et Qlabel
layoutCaractere = new QVBoxLayout; // layout contenant la spinbox
perso = new QPushButton("&Personnaliser le nombre de caractères");
perso->setToolTip("choisir le nombre de caractère pour le mot de passe");
perso->setFont(QFont("digital", 12));
perso->setStyleSheet("background-color: rgb(236, 201, 248)");
layoutCaractere->addSpacing(10);
layoutCaractere->addWidget(perso);
boxCaractere->setLayout(layoutCaractere);
layoutSpace = new QHBoxLayout;
space = new QLabel("Le programme va vous proposer 10 mots de passe differents<br />");
space->setAlignment(Qt::AlignCenter);
layoutSpace ->addWidget(space);
layoutGenerer = new QHBoxLayout;
generer = new QPushButton ("&GENERER");
generer->setFont(QFont("digital", 16));
generer->setStyleSheet("background-color: rgb(236, 201, 248)");
generer->setCursor(Qt::PointingHandCursor);
generer->setToolTip("générer le mot de passe");
layoutGenerer->addWidget(generer);
layoutSpace2 = new QHBoxLayout;
space2 = new QLabel("<br />");
layoutSpace2->addWidget(space2);
boutonsLayout = new QHBoxLayout;
m_about = new QPushButton ("A &Propos");
m_about->setToolTip("à propos");
m_about->setFont(QFont("digital", 14));
m_about->setStyleSheet("background-color: rgb(236, 201, 248)");
aide = new QPushButton("&Aide");
aide->setToolTip("aide");
aide->setFont(QFont("digital", 14));
aide->setStyleSheet("background-color: rgb(236, 201, 248)");
m_quitter = new QPushButton( "&Quitter");
m_quitter->setToolTip("Quitter");
m_quitter->setFont(QFont("digital", 14));
m_quitter->setStyleSheet("background-color: rgb(236, 201, 248)");
boutonsLayout->addWidget(m_about);
boutonsLayout->addWidget(aide);
boutonsLayout->addWidget(m_quitter);
layoutPrincipal->addWidget(label);
layoutPrincipal->addWidget(utilisateur);
layoutPrincipal->addWidget(box);
layoutPrincipal->addWidget(nbCaract);
layoutPrincipal->addWidget(boxCaractere);
layoutPrincipal->addLayout(layoutSpace);
layoutPrincipal->addLayout(layoutGenerer);
layoutPrincipal->addLayout(layoutSpace2);
layoutPrincipal->addLayout(boutonsLayout);
setLayout(layoutPrincipal);
QObject::connect(m_quitter, SIGNAL(clicked()), qApp, SLOT(quit()));
QObject::connect(m_about, SIGNAL(clicked()), this, SLOT(ouvrirAbout()));
QObject::connect(aide, SIGNAL(clicked()), this, SLOT(Aide()));
QObject::connect(generer, SIGNAL(clicked()), this, SLOT(genererCode()));
QObject::connect(perso, SIGNAL(clicked()), this, SLOT(personnaliser()));
}
void Fenetre::ouvrirAbout()
{
QMessageBox::about(this,"MDP Générator", "Merci d'utiliser <strong>MDP Générator</strong>"
"<br /><br />MDP Générator est un Générateur de mot de passe, "
"<br />Développé par Micmic : codé en c++ avec une interface produite avec Qt"
"<br />Version 2.0, codé le 12 Janvier 2009 !"
"<br /><br />vous pouvez générer des mots de passe, des clés WEP, WAP, de cryptage,etc.... ");
setFont(QFont("digital", 12));
}
void Fenetre::genererCode()
{
srand(time(NULL));
//QString code;
if(nom->text().isEmpty() || prenom->text().isEmpty())
{
QMessageBox::critical(this, "Erreur", "Veuillez entrer un nom et un prénom");
return;
}
if(loop ==0)
{
QMessageBox::critical(this,"MDP Générator", "vous devez d'abord choisir le nombre de caractères");
return;
}
else
{
if(utilis ->isChecked())
{
const char spe[] = {'&', '~', '#', 'ç', '@', '£', '$', '%', 'µ', '§'}; // max = 9
int MAX =9, MIN=1;
QString str_nom = nom->text();
int n_max = str_nom.size();
QString str_prenom = prenom->text();
int p_max = str_prenom.size();
if (loop ==3)
{
for (int i=0; i < 10; i++)
{
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code +="\n";
}
}
else if(loop == 4)
{
for (int i=0; i < 10; i++)
{
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
code +="\n";
}
}
else if (loop == 5)
{
for (int i=0; i < 10; i++)
{
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
code +="\n";
}
}
else if (loop == 6)
{
for (int i=0; i < 10; i++)
{
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
code +="\n";
}
}
else if (loop == 7)
{
for (int i=0; i < 10; i++)
{
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
code +="\n";
}
}
else if (loop == 8)
{
for (int i=0; i < 10; i++)
{
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
code +="\n";
}
}
else if (loop == 9)
{
for (int i=0; i < 10; i++)
{
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
code +="\n";
}
}
else if (loop == 10)
{
for (int i=0; i < 10; i++)
{
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += str_nom[(rand() % ((n_max-1) - MIN +1)) + MIN];
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code += str_prenom[(rand() % ((p_max-1) - MIN +1)) + MIN];
code +=spe[(rand() % (MAX - MIN + 1)) + MIN];
code +=" ";
code +="\n";
}
}
}
else if (utilis_2 -> isChecked())
{
QString str2_nom = nom->text();
QString str2_prenom = prenom->text();
int min_num =1900, max_num = 2010;
int n_max =10, n_min =0;
int hasard = ((rand () % (n_max - n_min +1)) - n_min);
if ((hasard%2)==0)
{
for (int i=0; i < 10; i++)
{
code += str2_nom[0];
code += str2_nom[1];
code += str2_nom[2];
code += "_";
code += str2_prenom[0];
code += str2_prenom[1];
code += str2_prenom[2];
code += QString ::number (int((rand() % (max_num - min_num +1)) + min_num), 10);
code +=" ";
code += "\n";
}
code += "\n";
}
else
{
for (int i=0; i < 10; i++)
{
code += str2_prenom[0];
code += str2_prenom[1];
code += str2_prenom[2];
code += "_";
code += str2_nom[0];
code += str2_nom[1];
code += str2_nom[2];
code += QString ::number (int((rand() % (max_num - min_num +1)) + min_num), 10);
code +=" ";
code += "\n";
}
code += "\n";
}
}
else if (maj ->isChecked())
{
int MAX = 25, MIN =1;
const char maj[] = {'A', 'B', 'C', 'D','E', 'F', 'G', 'H', 'I', 'J', // max = 25
'K', 'L', 'M', 'N','O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z'};
for (int j=0; j<10; j++)
{
code+="\t";
for (int i=0; i < loop; i++)
{
code += maj[(rand() % (MAX - MIN + 1)) + MIN];
code += " ";
}
code += "\n";
}
}
else if (min->isChecked())
{
int MAX = 25, MIN =1;
const char min[] = {'a','b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', // max = 25
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'};
for (int j=0; j<10; j++)
{
code+="\t";
for (int i=0; i < loop; i++)
{
code += min[(rand() % (MAX - MIN + 1)) + MIN];
code += " ";
}
code += "\n";
}
}
else if(num->isChecked())
{
int MAX = 9, MIN =1;
const char num[] = {'0', '1', '2', '3','4', '5', '6', '7', '8', '9'}; // max = 9
for (int j=0; j<10; j++)
{
code+="\t";
for (int i=0; i < loop; i++)
{
code += num[(rand() % (MAX - MIN + 1)) + MIN];
code += " ";
}
code += "\n";
}
}
else if(spe->isChecked())
{
int MAX = 9, MIN =1;
const char spe[] = {'&', '~', '#', 'ç', '@', '£', '$', '%', 'µ', '§'}; // max = 9
for (int j=0; j<10; j++)
{
code+="\t";
for (int i=0; i < loop; i++)
{
code += spe[(rand() % (MAX - MIN + 1)) + MIN];
code += " ";
}
code += "\n";
}
}
else if(mix->isChecked())
{
int MAX = 70, MIN =1;
const char mix[] = {'a','b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', // max = 70
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T','U', 'V', 'W', 'X',
'Y', 'Z', '0', '1', '2', '3','4', '5', '6', '7',
'8', '9', '&', '~', '#', 'ç', '@', '£', '$', '%',
'µ', '§'};
for (int j=0; j<10; j++)
{
code+="\t";
for (int i=0; i < loop; i++)
{
code += mix[(rand() % (MAX - MIN + 1)) + MIN];
code += " ";
}
code += "\n";
}
}
FenCodeGenere *fenetreCode = new FenCodeGenere(code, this);
fenetreCode->exec();
}
}
void Fenetre::personnaliser()
{
if (utilis->isChecked())
{
bool ok;
int i = QInputDialog::getInteger(this, tr("Personnaliser le mot de passe"),
tr("nombre de caracteres:"), 1, 3, 10, 1, &ok);
loop = i;
}
else if (utilis_2->isChecked())
{
bool ok;
int i = QInputDialog::getInteger(this, tr("Personnaliser le mot de passe"),
tr("nombre de caracteres fixé à:"), 1, 10, 10, 1, &ok);
loop = i;
}
else if( maj->isChecked() || min->isChecked() || num->isChecked() || spe->isChecked() || mix->isChecked())
{
bool ok;
int i = QInputDialog::getInteger(this, tr("Personnaliser le mot de passe"),
tr("nombre de caracteres:"), 1, 1, 50, 1, &ok);
loop = i;
}
}
void Fenetre::Aide()
{
QMessageBox::about(this,"MDP Générator", "Merci d'utiliser <strong>MDP Générator</strong>"
"<br /><br />1- Vous devez cocher une case pour choisir les caracteres désirés"
"<br />2- Cliquer sur \"Personnaliser le nombre de caracteres\""
"<br />3- choisir le nombre dans la fenetre ouverte en cliquant sur les fleches haut et bas"
"<br />4- Cliquer sur générer pour decouvrir les propositions de mot de passe");
}
main.cpp :
#include <QApplication>
#include "Fenetre.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QString locale = QLocale::system().name();
QTranslator translator;
translator.load(QString("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&translator);
Fenetre fenetre;
fenetre.show();
return app.exec();
}
Historique
- 26 janvier 2009 21:21:50 :
- mise a jour de la capture d'ecran
- 26 janvier 2009 21:29:50 :
- mise a jour et amelioration du mot de passe avec le nom et le prenom
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
login mdp C [ par shenron ]
Personne n'aurait pas un ptit code tt fait, pr mettre un login et mdp en C, avec ecriture des login et mdp ds un fichier binaire?Merci ^_^
Login mdp en C [ par shenron ]
Slt,Dites moi, je vais faire un acces login mot de passe sous C dans un prog, c koi la meilleure solution?1- Un fichier qui contient tous les login et
Generateur De Clés ! :) [ par erasor ]
Salu j'ai fait il y a pas longtemps un generateur de clés cd pour different jeux,mais voila il est est basé sur un aglghorithm HYPER HYPER simple ,c'e
un generateur de traffic reseau reseau [ par sousoumao ]
la j'ai un probleme au niveau de mon programme j'ai un generateur de traffic reseau mais le probleme c'est que je peux generer des packets avec 1 ms e
generateur d'mpulsions [ par Zadzed ]
bonjour ams forumistes, est-ce que vous pouvez m'aider a faire une application en c++builder, pour generer des impulsons par le port serie, dont je
générateur de nombre aléatoire [ par sadral ]
Je fais des recherches sur les générateurs de nombres pseudo-aléatoires et je cherche de la doc dessus,si il y en a qui ont fais des études dessus, ca
generateur [ par l0sth34d ]
bonjour, quelqu'un pourrais me donner un exemple pour un dialog qui a un bouton et quand j'appui sur le bouton, sa genere une phrase automatiquement e
Besoin d'un Générateur de Bruit Gaussien Généralisé [ par tawfik26 ]
Je travaille dans le domaine du traitement du signal et j'ai besoin d'un code source C d'un générateur de bruit gaussien généralis
Générer un .exe [ par Psyc0s ]
Bonjours, Je dois, à partir d'un programme, générer un fichier exécutable. Le "générateur" crée le .exe avec des
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
MATRICE TEMPLATEMATRICE TEMPLATE par hjr2610
Cliquez pour lire la suite par hjr2610 RE : SAC A DOS RE : SAC A DOS par hadjkaddour
Cliquez pour lire la suite par hadjkaddour
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|