begin process at 2012 02 10 02:14:53
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

API

 > [C/WIN32] GENERATEMDP : GÉNÉRATEUR DE MOT DE PASSE

[C/WIN32] GENERATEMDP : GÉNÉRATEUR DE MOT DE PASSE


 Information sur la source

Note :
9,5 / 10 - par 2 personnes
9,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :API Classé sous :mot, de, passe, generateur, api Niveau :Débutant Date de création :29/05/2006 Date de mise à jour :06/07/2006 19:24:54 Vu / téléchargé :5 565 / 357

Auteur : deck_bsd

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

 Description

Bon, et bien aujourd'hui il pleut en Belgique (étonant?) et je n'ai pas l'inspiration, mais j'ai tout de même envie de coder. Alors voila, j'ai (vite) fait un petit générateur de mot de passe. Rien d'exeptionnel.Mais cela évitera à certains j'espère de mettre le nom de leur chien en guise de mdp.


Source

  • /*
  • * Create by : deck_bsd.
  • * Date of creation : 29/05/2006.
  • * TASK : Generator of password.
  • */
  • #include <windows.h>
  • #include <time.h>
  • #define IDM_QUIT 11
  • #define IDM_HELP 12
  • /* Declare Windows procedure */
  • LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  • LRESULT CALLBACK PropoProc(HWND hwDlg, UINT message, WPARAM wParam, LPARAM lParam);
  • char * GenerateMDPaln(int iNbr,char * szPasswd);
  • char * GenerateMDPn(int iNbr,char * szPasswd);
  • char * GenerateMDPa(int iNbr,char * szPasswd);
  • char szClassName[ ] = "WindowsApp";
  • /* Variables globales */
  • HINSTANCE GlobalHInstance;
  • static HWND hwMDP, hwNbr;
  • static HWND hwButtonGenerate , hwButtonAl , hwButtonAln , hwButtonN;
  • int WINAPI WinMain (HINSTANCE hThisInstance,
  • HINSTANCE hPrevInstance,
  • LPSTR lpszArgument,
  • int nFunsterStil)
  • {
  • HWND hwnd; /* This is the handle for our window */
  • MSG messages; /* Here messages to the application are saved */
  • WNDCLASSEX wincl; /* Data structure for the windowclass */
  • HMENU hmMain,hmQuit,hmHelp;
  • /* The Window structure */
  • wincl.hInstance = hThisInstance;
  • wincl.lpszClassName = szClassName;
  • wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
  • wincl.style = CS_DBLCLKS; /* Catch double-clicks */
  • wincl.cbSize = sizeof (WNDCLASSEX);
  • /* Use default icon and mouse-pointer */
  • wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  • wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  • wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  • wincl.lpszMenuName = NULL; /* No menu */
  • wincl.cbClsExtra = 0; /* No extra bytes after the window class */
  • wincl.cbWndExtra = 0; /* structure or the window instance */
  • wincl.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
  • if (!RegisterClassEx (&wincl))
  • return 0;
  • hmQuit = CreateMenu();
  • AppendMenu(hmQuit,MF_STRING,IDM_QUIT,"Quit");
  • hmMain = CreateMenu();
  • AppendMenu(hmMain,MF_POPUP,(UINT)hmQuit,"&File");
  • hmHelp = CreateMenu();
  • AppendMenu(hmHelp,MF_STRING,IDM_HELP,"About ...");
  • AppendMenu(hmMain,MF_POPUP,(UINT)hmHelp,"&?");
  • hwnd = CreateWindowEx (
  • 0, /* Extended possibilites for variation */
  • szClassName, /* Classname */
  • "GenerateMDP", /* Title Text */
  • WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX, /* default window */
  • CW_USEDEFAULT, /* Windows decides the position */
  • CW_USEDEFAULT, /* where the window ends up on the screen */
  • 200, /* The programs width */
  • 170, /* and height in pixels */
  • HWND_DESKTOP, /* The window is a child-window to desktop */
  • hmMain, /* No menu */
  • hThisInstance, /* Program Instance handler */
  • NULL /* No Window Creation data */
  • );
  • ShowWindow (hwnd, nFunsterStil);
  • GlobalHInstance = hThisInstance;
  • while (GetMessage (&messages, NULL, 0, 0))
  • {
  • if(messages.message == WM_KEYDOWN){
  • switch(messages.wParam){
  • case VK_RETURN : int iNbr=0;
  • char szNbr[2+1];
  • SetFocus(hwButtonGenerate);
  • GetWindowText(hwNbr,szNbr,3);
  • iNbr = atoi(szNbr);
  • if(!iNbr){
  • MessageBox(hwnd,"Please, the number of characters must be > 0","Error",MB_OK | MB_ICONINFORMATION);
  • break;
  • }
  • char * szPasswd;
  • szPasswd = (char*)malloc(sizeof(char)*(iNbr+1));
  • if(szPasswd == NULL){
  • MessageBox(NULL,"Function : malloc()","Error",MB_OK | MB_ICONERROR);
  • SetFocus(hwNbr);
  • break;
  • }
  • _beep(1000,200);
  • if((SendMessage(hwButtonN,BM_GETCHECK,0,0)) == BST_CHECKED)
  • SetWindowText(hwMDP,GenerateMDPn(iNbr,szPasswd));
  • if((SendMessage(hwButtonAln,BM_GETCHECK,0,0)) == BST_CHECKED)
  • SetWindowText(hwMDP,GenerateMDPaln(iNbr,szPasswd));
  • if((SendMessage(hwButtonAl,BM_GETCHECK,0,0)) == BST_CHECKED)
  • SetWindowText(hwMDP,GenerateMDPa(iNbr,szPasswd));
  • free(szPasswd);
  • break;
  • }
  • }
  • TranslateMessage(&messages);
  • DispatchMessage(&messages);
  • }
  • return messages.wParam;
  • }
  • LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  • { HWND hwLabelNbr;
  • int iNbr=0;
  • char szNbr[2+1];
  • switch (message)
  • {
  • case WM_CREATE :
  • hwLabelNbr = CreateWindow("static","Nbr of characters :",WS_CHILD | WS_VISIBLE,
  • 20,20,150,20,hwnd,NULL,GlobalHInstance,NULL);
  • hwNbr = CreateWindow("edit","0",WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER | ES_NUMBER,
  • 150,20,20,20,hwnd,NULL,GlobalHInstance,NULL);
  • hwMDP = CreateWindow("edit","",WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL | ES_READONLY,
  • 20,45,150,20,hwnd,NULL,GlobalHInstance,NULL);
  • hwButtonGenerate = CreateWindow("button","Generate",WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
  • 60,100,70,20,hwnd,(HMENU)1,GlobalHInstance,NULL);
  • hwButtonAln = CreateWindow("button","Alphanum",WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
  • 20,70,75,20,hwnd,(HMENU)2,GlobalHInstance,NULL);
  • hwButtonN = CreateWindow("button","Num",WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
  • 95,70,40,20,hwnd,(HMENU)3,GlobalHInstance,NULL);
  • hwButtonAl = CreateWindow("button","Alpha",WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
  • 145,70,60,20,hwnd,(HMENU)4,GlobalHInstance,NULL);
  • HFONT PoliceTahoma,PoliceComic;
  • PoliceTahoma = CreateFont(14,0,0,0,0,0,0,0,0,0,0,0,0,"tahoma");
  • PoliceComic = CreateFont(17,0,0,0,0,0,TRUE,0,0,0,0,0,0,"comic sans MS");
  • SendMessage(hwMDP,WM_SETFONT,(long)PoliceTahoma,0);
  • SendMessage(hwNbr,WM_SETFONT,(long)PoliceTahoma,0);
  • SendMessage(hwButtonGenerate,WM_SETFONT,(long)PoliceTahoma,0);
  • PoliceTahoma = CreateFont(13,0,0,0,0,0,0,0,0,0,0,0,0,"tahoma");
  • SendMessage(hwButtonAln,WM_SETFONT,(long)PoliceTahoma,0);
  • SendMessage(hwButtonN,WM_SETFONT,(long)PoliceTahoma,0);
  • SendMessage(hwButtonAl,WM_SETFONT,(long)PoliceTahoma,0);
  • SendMessage(hwLabelNbr,WM_SETFONT,(long)PoliceComic,0);
  • SetFocus(hwNbr);
  • break;
  • case WM_COMMAND : switch(HIWORD(wParam)){
  • case BN_CLICKED : switch(LOWORD(wParam)){
  • case 1 :
  • GetWindowText(hwNbr,szNbr,3);
  • iNbr = atoi(szNbr);
  • if(!iNbr){
  • MessageBox(hwnd,"Please, the number of characters must be > 0","Error",MB_OK | MB_ICONINFORMATION);
  • SetFocus(hwNbr);
  • break;
  • }
  • char * szPasswd;
  • szPasswd = (char*)malloc(sizeof(char)*(iNbr+1));
  • if(szPasswd == NULL){
  • MessageBox(NULL,"Function : malloc()","Error",MB_OK | MB_ICONERROR);
  • }
  • _beep(1000,200);
  • if((SendMessage(hwButtonN,BM_GETCHECK,0,0)) == BST_CHECKED)
  • SetWindowText(hwMDP,GenerateMDPn(iNbr,szPasswd));
  • if((SendMessage(hwButtonAln,BM_GETCHECK,0,0)) == BST_CHECKED)
  • SetWindowText(hwMDP,GenerateMDPaln(iNbr,szPasswd));
  • if((SendMessage(hwButtonAl,BM_GETCHECK,0,0)) == BST_CHECKED)
  • SetWindowText(hwMDP,GenerateMDPa(iNbr,szPasswd));
  • free(szPasswd);
  • break;
  • case 2 : SendMessage(hwButtonN,BM_SETCHECK,(long)BST_UNCHECKED,0);
  • SendMessage(hwButtonAl,BM_SETCHECK,(long)BST_UNCHECKED,0);
  • break;
  • case 3 : SendMessage(hwButtonAln,BM_SETCHECK,(long)BST_UNCHECKED,0);
  • SendMessage(hwButtonAl,BM_SETCHECK,(long)BST_UNCHECKED,0);
  • break;
  • case 4 : SendMessage(hwButtonAln,BM_SETCHECK,(long)BST_UNCHECKED,0);
  • SendMessage(hwButtonN,BM_SETCHECK,(long)BST_UNCHECKED,0);
  • break;
  • case 11 : PostQuitMessage(0);
  • break;
  • case 12 : HGLOBAL hgMemory;
  • LPDLGTEMPLATE dltDlgBox;
  • LPWORD lpwWord;
  • LPWSTR lpwsUnicode;
  • hgMemory = GlobalAlloc(GPTR,512);
  • if(!hgMemory) break;
  • dltDlgBox = (LPDLGTEMPLATE) hgMemory;
  • dltDlgBox->style = WS_CAPTION | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX | DS_MODALFRAME;
  • dltDlgBox->cx=210;
  • dltDlgBox->cy=100;
  • dltDlgBox->x=GetSystemMetrics(SM_CXSCREEN)/6;
  • dltDlgBox->y=GetSystemMetrics(SM_CYSCREEN)/6;
  • lpwWord = (LPWORD) (dltDlgBox + 1);
  • lpwsUnicode = (LPWSTR) (lpwWord + 2);
  • MultiByteToWideChar(CP_ACP,0,"A propos de :",-1,lpwsUnicode,128);
  • DialogBoxIndirect(GlobalHInstance,dltDlgBox,0,(DLGPROC)PropoProc);
  • GlobalFree(hgMemory);
  • break;
  • }
  • break;
  • }
  • break;
  • case WM_DESTROY:
  • PostQuitMessage (0);
  • break;
  • default:
  • return DefWindowProc (hwnd, message, wParam, lParam);
  • }
  • return 0;
  • }
  • /* TASK : génère un code alphanumérique. */
  • char * GenerateMDPaln(int iNbr,char * szPasswd){
  • int iCount;
  • BOOL boSwitch;
  • unsigned int uiGen;
  • srand(time(NULL));
  • for(iCount=0; iCount < iNbr ; iCount++){
  • boSwitch = rand()%2;
  • switch(boSwitch){
  • case 0 :uiGen = (34+ (rand()%91));break;
  • case 1 :uiGen = (48+ (rand()%9));break;
  • }
  • szPasswd[iCount] = uiGen;
  • }
  • szPasswd[iNbr] = '\0';
  • return szPasswd;
  • }
  • /* TASK : Génère un code numérique. */
  • char * GenerateMDPn(int iNbr,char * szPasswd){
  • int iCount;
  • unsigned int uiGen;
  • srand(time(NULL));
  • for(iCount = 0 ; iCount < iNbr ; iCount++){
  • uiGen = (48+(rand()%9));
  • szPasswd[iCount] = uiGen;
  • }
  • szPasswd[iNbr] = '\0';
  • return szPasswd;
  • }
  • /* TASK : Génère un code alphabétique. */
  • char * GenerateMDPa(int iNbr,char * szPasswd){
  • int iCount;
  • BOOL boSwitch;
  • unsigned int uiGen;
  • srand(time(NULL));
  • for(iCount = 0 ; iCount < iNbr ; iCount++){
  • boSwitch = rand()%2;
  • switch(boSwitch){
  • case 0 : uiGen = (34+(rand()%13));break;
  • case 1 : uiGen = (58+(rand()%67));break;
  • }
  • szPasswd[iCount] = uiGen;
  • }
  • szPasswd[iNbr] = '\0';
  • return szPasswd;
  • }
  • LRESULT CALLBACK PropoProc(HWND hwDlg, UINT message, WPARAM wParam, LPARAM lParam){
  • HWND hwGroup,hwButtonOk,hwLabelInfo;
  • HWND hwButtonSite,hwButtonMail;
  • switch(message){
  • case WM_INITDIALOG :
  • hwGroup = CreateWindow("button","GenerateMDP",WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
  • 10,10,400,160,hwDlg,NULL,GlobalHInstance,NULL);
  • hwButtonOk = CreateWindow("button","OK",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
  • 16,146,30,20,hwDlg,(HMENU)111,GlobalHInstance,NULL);
  • hwLabelInfo = CreateWindow("static","Créer par : Deck_bsd \n\nVersion : 1.0 \n\nLicense : Freeware",WS_CHILD | WS_VISIBLE,
  • 120,30,150,90,hwDlg,NULL,GlobalHInstance,NULL);
  • hwButtonSite = CreateWindow("button","http://deck-bsd.eurower.net",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
  • 120,115,200,20,hwDlg,(HMENU)1111,GlobalHInstance,NULL);
  • hwButtonMail = CreateWindow("button","deck_bsd01@yahoo.fr",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
  • 120,140,200,20,hwDlg,(HMENU)11111,GlobalHInstance,NULL);
  • HFONT PoliceComic;
  • HFONT PoliceVerdana;
  • PoliceComic = CreateFont(15,0,0,0,0,0,0,0,0,0,0,0,0,"comic sans MS");
  • PoliceVerdana = CreateFont(15,0,0,0,0,0,0,0,0,0,0,0,0,"verdana");
  • SendMessage(hwGroup,WM_SETFONT,(long)PoliceComic,0);
  • SendMessage(hwButtonOk,WM_SETFONT,(long)PoliceComic,0);
  • SendMessage(hwLabelInfo,WM_SETFONT,(long)PoliceVerdana,0);
  • SendMessage(hwButtonSite,WM_SETFONT,(long)PoliceVerdana,0);
  • SendMessage(hwButtonMail,WM_SETFONT,(long)PoliceVerdana,0);
  • break;
  • case WM_COMMAND :
  • if(HIWORD(wParam) == BN_CLICKED){
  • switch(LOWORD(wParam)){
  • case 111 :
  • EndDialog(hwDlg,0);
  • break;
  • case 1111 : ShellExecute(NULL,"open","http://deck-bsd.eurower.net",0,NULL,SW_MAXIMIZE);
  • break;
  • case 11111 : ShellExecute(NULL,"open","mailto:deck_bsd01@yahoo.fr",0,NULL,SW_MAXIMIZE);
  • break;
  • }
  • }
  • break;
  • case WM_CLOSE :
  • EndDialog(hwDlg,0);
  • break;
  • }
  • return 0;
  • }
/*
 * Create by : deck_bsd.
 * Date of creation : 29/05/2006.
 * TASK : Generator of password.
 */

#include <windows.h>
#include <time.h>

#define IDM_QUIT 11
#define IDM_HELP 12

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK PropoProc(HWND hwDlg, UINT message, WPARAM wParam, LPARAM lParam);
char * GenerateMDPaln(int iNbr,char * szPasswd);
char * GenerateMDPn(int iNbr,char * szPasswd);
char * GenerateMDPa(int iNbr,char * szPasswd);


char szClassName[ ] = "WindowsApp";

/* Variables globales */
HINSTANCE GlobalHInstance;
static HWND hwMDP, hwNbr;
static HWND hwButtonGenerate , hwButtonAl , hwButtonAln , hwButtonN;

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
    HMENU hmMain,hmQuit,hmHelp;

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */

    wincl.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);


    if (!RegisterClassEx (&wincl))
        return 0;
        
    hmQuit = CreateMenu();
    AppendMenu(hmQuit,MF_STRING,IDM_QUIT,"Quit");
    hmMain = CreateMenu();
    AppendMenu(hmMain,MF_POPUP,(UINT)hmQuit,"&File");
    
    hmHelp = CreateMenu();
    AppendMenu(hmHelp,MF_STRING,IDM_HELP,"About ...");
    AppendMenu(hmMain,MF_POPUP,(UINT)hmHelp,"&?");

    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "GenerateMDP",       /* Title Text */
           WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           170,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           hmMain,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );


    ShowWindow (hwnd, nFunsterStil);
    
    GlobalHInstance = hThisInstance;


    while (GetMessage (&messages, NULL, 0, 0))
    {
        if(messages.message == WM_KEYDOWN){
            switch(messages.wParam){
                case VK_RETURN :   int iNbr=0;
                                   char szNbr[2+1];
                                   
                                   SetFocus(hwButtonGenerate);
                                                         
                                   GetWindowText(hwNbr,szNbr,3);
                                   iNbr = atoi(szNbr);
                                   if(!iNbr){
                                       MessageBox(hwnd,"Please, the number of characters must be > 0","Error",MB_OK | MB_ICONINFORMATION);
                                       break;
                                   }
                                                         
                                   char * szPasswd;
                                                         
                                   szPasswd = (char*)malloc(sizeof(char)*(iNbr+1));
                                   if(szPasswd == NULL){
                                       MessageBox(NULL,"Function : malloc()","Error",MB_OK | MB_ICONERROR);
                                       SetFocus(hwNbr);
                                       break;
                                   }
                                                         
                                   _beep(1000,200);
                                   
                                   if((SendMessage(hwButtonN,BM_GETCHECK,0,0)) == BST_CHECKED)
                                   SetWindowText(hwMDP,GenerateMDPn(iNbr,szPasswd));
                                                         
                                   if((SendMessage(hwButtonAln,BM_GETCHECK,0,0)) == BST_CHECKED)
                                   SetWindowText(hwMDP,GenerateMDPaln(iNbr,szPasswd));
                                   
                                   if((SendMessage(hwButtonAl,BM_GETCHECK,0,0)) == BST_CHECKED)
                                   SetWindowText(hwMDP,GenerateMDPa(iNbr,szPasswd));
                                                         
                                   free(szPasswd);
                break;
            }
        }
        TranslateMessage(&messages);
        DispatchMessage(&messages);
    }

    return messages.wParam;
}



LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{   HWND hwLabelNbr;
    
    int iNbr=0;
    char szNbr[2+1];
    
    switch (message)
    {
        case WM_CREATE :
             hwLabelNbr = CreateWindow("static","Nbr of characters :",WS_CHILD | WS_VISIBLE,
                          20,20,150,20,hwnd,NULL,GlobalHInstance,NULL);
             hwNbr = CreateWindow("edit","0",WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER | ES_NUMBER,
                     150,20,20,20,hwnd,NULL,GlobalHInstance,NULL);
             hwMDP = CreateWindow("edit","",WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL | ES_READONLY,
                     20,45,150,20,hwnd,NULL,GlobalHInstance,NULL);
             hwButtonGenerate = CreateWindow("button","Generate",WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                                60,100,70,20,hwnd,(HMENU)1,GlobalHInstance,NULL);
                                
             hwButtonAln = CreateWindow("button","Alphanum",WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                           20,70,75,20,hwnd,(HMENU)2,GlobalHInstance,NULL);
             hwButtonN = CreateWindow("button","Num",WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                         95,70,40,20,hwnd,(HMENU)3,GlobalHInstance,NULL);
             hwButtonAl = CreateWindow("button","Alpha",WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                          145,70,60,20,hwnd,(HMENU)4,GlobalHInstance,NULL);
                                
             HFONT PoliceTahoma,PoliceComic;
             
             PoliceTahoma = CreateFont(14,0,0,0,0,0,0,0,0,0,0,0,0,"tahoma");
             PoliceComic = CreateFont(17,0,0,0,0,0,TRUE,0,0,0,0,0,0,"comic sans MS");
             SendMessage(hwMDP,WM_SETFONT,(long)PoliceTahoma,0);
             SendMessage(hwNbr,WM_SETFONT,(long)PoliceTahoma,0);
             SendMessage(hwButtonGenerate,WM_SETFONT,(long)PoliceTahoma,0);
             
             PoliceTahoma = CreateFont(13,0,0,0,0,0,0,0,0,0,0,0,0,"tahoma");
             SendMessage(hwButtonAln,WM_SETFONT,(long)PoliceTahoma,0);
             SendMessage(hwButtonN,WM_SETFONT,(long)PoliceTahoma,0);
             SendMessage(hwButtonAl,WM_SETFONT,(long)PoliceTahoma,0);
             
             SendMessage(hwLabelNbr,WM_SETFONT,(long)PoliceComic,0);
             
             SetFocus(hwNbr);
            break;
        case WM_COMMAND : switch(HIWORD(wParam)){
                              case BN_CLICKED : switch(LOWORD(wParam)){
                                                    case 1 :
                                                         
                                                         GetWindowText(hwNbr,szNbr,3);
                                                         iNbr = atoi(szNbr);
                                                         if(!iNbr){
                                                             MessageBox(hwnd,"Please, the number of characters must be > 0","Error",MB_OK | MB_ICONINFORMATION);
                                                             SetFocus(hwNbr);
                                                             break;
                                                         }
                                                         
                                                         char * szPasswd;
                                                         
                                                         szPasswd = (char*)malloc(sizeof(char)*(iNbr+1));
                                                         if(szPasswd == NULL){
                                                             MessageBox(NULL,"Function : malloc()","Error",MB_OK | MB_ICONERROR);
                                                         }
                                                         
                                                         _beep(1000,200);
                                                         
                                                         if((SendMessage(hwButtonN,BM_GETCHECK,0,0)) == BST_CHECKED)
                                                         SetWindowText(hwMDP,GenerateMDPn(iNbr,szPasswd));
                                                         
                                                         if((SendMessage(hwButtonAln,BM_GETCHECK,0,0)) == BST_CHECKED)
                                                         SetWindowText(hwMDP,GenerateMDPaln(iNbr,szPasswd));
                                                         
                                                         if((SendMessage(hwButtonAl,BM_GETCHECK,0,0)) == BST_CHECKED)
                                                         SetWindowText(hwMDP,GenerateMDPa(iNbr,szPasswd));
                                                         
                                                         free(szPasswd);
                                                    break;
                                                    case 2 : SendMessage(hwButtonN,BM_SETCHECK,(long)BST_UNCHECKED,0);
                                                             SendMessage(hwButtonAl,BM_SETCHECK,(long)BST_UNCHECKED,0);
                                                    break;
                                                    case 3 : SendMessage(hwButtonAln,BM_SETCHECK,(long)BST_UNCHECKED,0);
                                                             SendMessage(hwButtonAl,BM_SETCHECK,(long)BST_UNCHECKED,0);
                                                    break;
                                                    case 4 : SendMessage(hwButtonAln,BM_SETCHECK,(long)BST_UNCHECKED,0);
                                                             SendMessage(hwButtonN,BM_SETCHECK,(long)BST_UNCHECKED,0);
                                                    break;
                                                    case 11 : PostQuitMessage(0);
                                                    break;
                                                    
                                                    case 12 : HGLOBAL hgMemory;
                                                              LPDLGTEMPLATE dltDlgBox;
                                                              LPWORD lpwWord;
                                                              LPWSTR lpwsUnicode;
                                                              
                                                              hgMemory = GlobalAlloc(GPTR,512);
                                                              if(!hgMemory) break;
                                                              
                                                              dltDlgBox = (LPDLGTEMPLATE) hgMemory;
                                                              
                                                              dltDlgBox->style = WS_CAPTION | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX | DS_MODALFRAME;
                                                              dltDlgBox->cx=210;
                                                              dltDlgBox->cy=100;
                                                              dltDlgBox->x=GetSystemMetrics(SM_CXSCREEN)/6;
                                                              dltDlgBox->y=GetSystemMetrics(SM_CYSCREEN)/6;
                                                              
                                                              lpwWord = (LPWORD) (dltDlgBox + 1);
                                                              
                                                              lpwsUnicode = (LPWSTR) (lpwWord + 2);
                                                              
                                                              MultiByteToWideChar(CP_ACP,0,"A propos de :",-1,lpwsUnicode,128);
                                                              
                                                              DialogBoxIndirect(GlobalHInstance,dltDlgBox,0,(DLGPROC)PropoProc);
                                                              
                                                              GlobalFree(hgMemory);
                                                    break;
                                                }
                              break;
                          }
        break;
        case WM_DESTROY:
            PostQuitMessage (0);
            break;
        default:
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

/* TASK : génère un code alphanumérique. */
char * GenerateMDPaln(int iNbr,char * szPasswd){
     int iCount;
     BOOL boSwitch;
     unsigned int uiGen;
     
     srand(time(NULL));
     for(iCount=0; iCount < iNbr ; iCount++){
           boSwitch = rand()%2;
           switch(boSwitch){
               case 0 :uiGen = (34+ (rand()%91));break;
               case 1 :uiGen = (48+ (rand()%9));break;
           }
           szPasswd[iCount] = uiGen;
     }
     
     szPasswd[iNbr] = '\0';
     
     return szPasswd;
}

/* TASK : Génère un code numérique. */
char * GenerateMDPn(int iNbr,char * szPasswd){
     int iCount;
     unsigned int uiGen;
     
     srand(time(NULL));
     for(iCount = 0 ; iCount < iNbr ; iCount++){
                uiGen = (48+(rand()%9));
                szPasswd[iCount] = uiGen;
     }
     
     szPasswd[iNbr] = '\0';
     
     return szPasswd;
}

/* TASK : Génère un code alphabétique. */
char * GenerateMDPa(int iNbr,char * szPasswd){
     int iCount;
     BOOL boSwitch;
     unsigned int uiGen;
     
     srand(time(NULL));
     for(iCount = 0 ; iCount < iNbr ; iCount++){
                boSwitch = rand()%2;
                switch(boSwitch){
                    case 0 : uiGen = (34+(rand()%13));break;
                    case 1 : uiGen = (58+(rand()%67));break;
                }                
                szPasswd[iCount] = uiGen;
     }
     
     szPasswd[iNbr] = '\0';
     
     return szPasswd;
}


LRESULT CALLBACK PropoProc(HWND hwDlg, UINT message, WPARAM wParam, LPARAM lParam){
        HWND hwGroup,hwButtonOk,hwLabelInfo;
        HWND hwButtonSite,hwButtonMail;
        
        switch(message){
            case WM_INITDIALOG :
                 hwGroup = CreateWindow("button","GenerateMDP",WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
                                                                    10,10,400,160,hwDlg,NULL,GlobalHInstance,NULL);
                 hwButtonOk = CreateWindow("button","OK",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                                                     16,146,30,20,hwDlg,(HMENU)111,GlobalHInstance,NULL);
                 hwLabelInfo = CreateWindow("static","Créer par : Deck_bsd \n\nVersion : 1.0 \n\nLicense : Freeware",WS_CHILD | WS_VISIBLE,
                                                                     120,30,150,90,hwDlg,NULL,GlobalHInstance,NULL);
                 hwButtonSite = CreateWindow("button","http://deck-bsd.eurower.net",WS_VISIBLE | WS_CHILD  | BS_PUSHBUTTON,
                                                                     120,115,200,20,hwDlg,(HMENU)1111,GlobalHInstance,NULL);                          
                 hwButtonMail = CreateWindow("button","deck_bsd01@yahoo.fr",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
                                                                     120,140,200,20,hwDlg,(HMENU)11111,GlobalHInstance,NULL);                                                  
                 HFONT PoliceComic;
                 HFONT PoliceVerdana;
                 
                 PoliceComic = CreateFont(15,0,0,0,0,0,0,0,0,0,0,0,0,"comic sans MS");
                 PoliceVerdana = CreateFont(15,0,0,0,0,0,0,0,0,0,0,0,0,"verdana");
                 SendMessage(hwGroup,WM_SETFONT,(long)PoliceComic,0);
                 SendMessage(hwButtonOk,WM_SETFONT,(long)PoliceComic,0);
                 SendMessage(hwLabelInfo,WM_SETFONT,(long)PoliceVerdana,0);
                 SendMessage(hwButtonSite,WM_SETFONT,(long)PoliceVerdana,0);
                 SendMessage(hwButtonMail,WM_SETFONT,(long)PoliceVerdana,0);
                 
                 
                 break;
            case WM_COMMAND :
                 if(HIWORD(wParam) == BN_CLICKED){
                                   switch(LOWORD(wParam)){
                                       case 111 :
                                            EndDialog(hwDlg,0);
                                       break;
                                       case 1111 : ShellExecute(NULL,"open","http://deck-bsd.eurower.net",0,NULL,SW_MAXIMIZE);
                                       break;
                                       case 11111 : ShellExecute(NULL,"open","mailto:deck_bsd01@yahoo.fr",0,NULL,SW_MAXIMIZE);
                                       break;
                                   }
                 }
                 break;            
            case WM_CLOSE :
                 EndDialog(hwDlg,0);
                 break;
        }
        return 0;
}     


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
  • GenerateMDP.devTélécharger ce fichier [Réservé aux membres club]838 octets
  • GenerateMDP.exeTélécharger ce fichier [Réservé aux membres club]32 214 octets
  • main.cppTélécharger ce fichier [Réservé aux membres club]Voir ce fichier19 030 octets
  • main.oTélécharger ce fichier [Réservé aux membres club]10 122 octets
  • Makefile.winTélécharger ce fichier [Réservé aux membres club]809 octets

Télécharger le zip


 Historique

29 mai 2006 20:21:36 :
- Rectification d'une erreur
29 mai 2006 20:33:56 :
- orthographe
06 juillet 2006 19:23:25 :
- Ajout de la possiblité de choisir le code que l'on souhaite. Alpha , aplhanum , num (Attention Alphabétique contient aussi des caractères non compris dans l'alphabet).
06 juillet 2006 19:24:54 :
- modification du code.

 Sources du même auteur

Source avec Zip Source avec une capture [C/WIN32][DRIVER] DÉTECTION DE CRÉATION OU DE SUPPRESSION DE...
Source avec Zip Source avec une capture [C/WIN32] INJECTION DE DLL 2 MÉTHODES (REMOTETHREAD PROPRE &...
Source avec Zip Source avec une capture [C/WIN32][VISTA] EXEMPLE D'UTILISATION DES TRANSACTIONS.
Source avec Zip Source avec une capture [C/WIN32] GÉNÉRATEUR DE CODE POUR UNE INITIALISATION SPÉCIAL...
Source avec Zip Source avec une capture [C/WIN32] AFFICHE TOUT LES LIENS D'UNE PAGE (X)HTML.

 Sources de la même categorie

Source avec Zip WIN32 TLS LENT par dguilmain
Source avec Zip VIDER ELEMENTS DE CORBEILLE WINDOWS7 (WIN64) par BruNews
Source avec Zip Source avec une capture FIND TEXT (WIN64) par BruNews
Source avec Zip DELETE DIRECTORY (WIN64) par BruNews
Source avec Zip ENUM DIRECTORY (WIN64) par BruNews

 Sources en rapport avec celle ci

Source avec Zip VIDER ELEMENTS DE CORBEILLE WINDOWS7 (WIN64) par BruNews
Source avec Zip Source avec une capture [C++] GENERATEUR DE PSEUDO par Miwik
Source avec Zip PASSWORD GENERATOR par stillfelil
Source avec Zip CRYPTAGE/DÉCRYPTAGE DE FICHERS par Pamaury
Source avec Zip PASSWORD GENERATOR par Irix

Commentaires et avis

Commentaire de Kaid le 29/05/2006 19:52:11

szPasswd = (char*)malloc(sizeof(char)*iNbr);

puis

for(iCount=0; iCount < iNbr ; iCount++){
// ..
}
szPasswd[iNbr] = '\0';

Tu n'aurais pas oublié d'allouer la place pour le '\0' ?

Commentaire de deck_bsd le 29/05/2006 20:22:32

LOL bienvu, c'est pour voir si vous regardé vraiment. (hum la bourde)

Commentaire de Samuel17_50 le 26/06/2006 16:06:50

Sympa mais vraiment compliqué le code !!!

Commentaire de deck_bsd le 27/06/2006 10:08:30

Compliqué? le code pour générer le mot de passe ? si tu parle de la totalité du code, ben c'est le minimum requi pour avoir une fenetre , une editbox et un bouton mdr, bon daccord j'ai ajouter le menu ;) .

Commentaire de Samuel17_50 le 28/06/2006 14:21:22

Non, je voulait parler du code que générait ton programme. lol

Commentaire de deck_bsd le 29/06/2006 17:31:56

loool ben c'est un bon mot de passe lol , je pourrai sans doute demander un choix à l'utilisateur , si il veut un code alphabetique , numérique ou alphanumérique.

Commentaire de Samuel17_50 le 30/06/2006 13:34:16

Ca serait une très bonne idée.

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

vérification du mot de passe [ par biscot19 ] Bonjour,Je cherche comment vérifier un mot de passe NT en C++.J'ai vu que la fonction NetUserChangePassword permettait de le faire mais comme son nom acces base de donnée DAO protégée par mot de passe [ par Frederyck ] Bonjour,Alors je voudrais savoir comment faire pour acceder à une base de donnée Access 97 via DAO quand celle ci est protégée par mot de passe.J'aime Controler impression [ par none77 ] Bonjour,j'aimerais controler les impressions a l'aide de mot de passe.En fait dès ke lon veut imprimer(sous Word par exemple), on demande un mot de p comment protéger l'ouverture d'un fichier ? [ par f1cobra ] Bonjour, je voudrais protéger l'ouverture d'un fichier excell par un mot de passe, de manière a ce que seules les personnes ayant le mot de passe puis Mot de passe à l'ouverture d'une BDD [ par lyricman ] Bonjourje fais un programme en C++ (Borland C++ Builder 6) avec une base de données.le pb est que chaque fois que j'exécute mon programme, il me deman détecter un mot de passe [ par Vortex99011 ] Bonjour,j'ai créé un programme " hook " qui récupère les données tapées au clavier. Le seul problème, c'est que ca récupère également les mot de passe creer un mot de passe (web) [ par Raphael2 ] bonjour,j'essai de creer un site où il faut que le visiteur entre un mot de passe pour accéder à une autre page.Mon probleme est de creer et de faire mot de passe [ par scully2501 ] bonjourj'ai créér un site en php mais j'aimerai protéger ma page administration ("adm.php")avec un mot de passe hautement sécurisé pour que personne d mot de passe [ par jeromedu94 ] bonjour,J'aimerais savoir comment est ce qu'on fait pour mettre un mot de passe à un fichier.J'ai regardé quelques exemple de sources, mais j'ai pas r mot de passe VC++ [ par fat52 ] je voudrais saisir un mot de passe sous VC++ et afficher des * pour chaque lettre ecrite par l'utilisateur


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
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,640 sec (3)

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