begin process at 2012 05 27 16:34:35
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Application

 > 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

Note :
Aucune note
Catégorie :Application Classé sous :générateur, mot passe, mdp, generateur, micmic Niveau :Débutant Date de création :19/01/2009 Date de mise à jour :26/01/2009 21:29:50 Vu / téléchargé :8 774 / 811

Auteur : micmic92

Ecrire un message privé
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
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();
}


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 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

GÉNÉRATEUR DE CLASSE QT

 Sources de la même categorie

Source avec Zip Source avec une capture PROGRAMME DE SUDOKU par AffreuxJojp
Source avec Zip EVALUATEUR D'EXPRESSION ARITHMÉTIQUE par matrx180vTitanium
Source avec Zip Source avec une capture QBIBLIO GESTION DES PRÊTS par conatic
Source avec Zip Source avec une capture QL-CHATROOM V 1.0 par mature
Source avec Zip Source avec une capture GEOLOCALISATION par ganjarasta

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture GÉNÉRATEUR FM EXPÉRIMENTAL par tontonCD
Source avec une capture GÉNÉRATEUR DE CLÉS SUR 26 DIGITS AU FORMAT HEXADÉCIMAL par besilent
Source avec Zip Source avec une capture [C++] GENERATEUR DE PSEUDO par Miwik
GÉNÉRATEUR DE CLASSE QT par micmic92
Source avec Zip PASSWORD GENERATOR par stillfelil

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire


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&#233;n&#233;rateur de bruit gaussien g&#233;n&#233;ralis Générer un .exe [ par Psyc0s ] Bonjours, Je dois, &#224; partir d'un programme, g&#233;n&#233;rer un fichier ex&#233;cutable. Le "g&#233;n&#233;rateur" cr&#233;e le .exe avec des


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,546 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales