IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Flash Pascal Discussion :

Générateur de mot de passe


Sujet :

Flash Pascal

  1. #1
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 070
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 070
    Points : 15 454
    Points
    15 454
    Billets dans le blog
    9
    Par défaut Générateur de mot de passe
    Bonjour !

    Il y avait quelque temps qu'il n'y avait plus de nouvelle discussion dans le forum FlashPascal. Je vous propose donc un générateur de mot de passe. J'ai utilisé la bibliothèque FlashCL.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
     
    (*----------------------------------------------------------------------------*)
    (* FlashPascal 2                                                              *)
    (* Générateur de mot de passe                                                 *)
    (* FlashCL : http://flashpascal.execute.re/FlashCL.php                        *)
    (* 03/09/2014 19:19:41                                                        *)
    (*----------------------------------------------------------------------------*)
     
    program Generateur;
     
    {$FRAME_WIDTH 540}
    {$FRAME_HEIGHT 400}
     
    uses
      Flash8, Classes, Controls, StdCtrls;
     
    const
      L = 'abcdefghijklmnopqrstuvwxyz';
      C = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      D = '0123456789';
      S = '!#$%&()*+,-./:;<=>?@[\]^_{|}~';
     
    function RandomWord(
      aLength: integer;
      aDigits: boolean;
      aCapitals: boolean;
      aLowerChars: boolean;
      aSpecialChars: boolean): string;
    var
      a: array[1..4]of integer;
      i: integer;
    begin
      i := 0;
      if aDigits then
      begin
        Inc(i);
        a[i] := 1;
      end;
      if aCapitals then
      begin
        Inc(i);
        a[i] := 2;
      end;
      if aLowerChars then
      begin
        Inc(i);
        a[i] := 3;
      end;
      if aSpecialChars then
      begin
        Inc(i);
        a[i] := 4;
      end;
      result := '';
      if i > 0 then
        while Length(result) < aLength do
          case a[Trunc(i * Random + 1)] of
            1: result := result + D[Trunc(10 * Random + 1)];
            2: result := result + C[Trunc(26 * Random + 1)];
            3: result := result + L[Trunc(26 * Random + 1)];
            4: result := result + S[Trunc(Length(s) * Random + 1)];
          end;
    end;
     
    var
      bb: array[1..4] of TCheckBox;
      ff: array[1..5] of TextField;
     
    type
      TCustomButton = class(MovieClip)
        caption: TextField;
        procedure DrawButton(backColor, topColor, bottomColor, width, height: integer);
      end;
      TButton = class(TCustomButton)
        constructor Create(left, top, width, height: integer; aCaption: string);
        procedure doClick;
        procedure onRelease; override;
      end;
     
    { TCustomButton }
     
    procedure TCustomButton.DrawButton(
      backColor,
      topColor,
      bottomColor,
      width,
      height: integer
    );
    begin
      BeginFill(backColor);
      LineStyle(1, topColor);
      MoveTo(0, height);
      LineTo(0, 0);
      LineTo(width, 0);
      LineStyle(1, bottomColor);
      LineTo(width, height);
      LineTo(0, height);
      EndFill;
    end;
     
    { TButton }
     
    constructor TButton.Create(left, top, width, height: integer; aCaption: string);
    var
      f: textFormat;
    begin
      inherited Create(nil, '', GetNextHighestDepth());
      _x := left;
      _y := top;
      DrawButton($D0D0D0, $E0E0E0, $808080, width, height);
      caption := TextField.Create(
        self,
        '',
        GetNextHighestDepth(),
        0,
        5,
        width,
        height
      );
      caption.text := aCaption;
      f := TextFormat.Create('Arial', 12);
      f.align := 'center';
      caption.SetTextFormat(0, Length(caption.text), f);
      onPress := doClick;
    end;
     
    procedure TButton.doClick;
    var
      i: integer;
    begin
      DrawButton(
        $C0C0C0,
        $808080,
        $E0E0E0,
        integer(caption._width),
        integer(caption._height)
      );
      ff[5].text := '';
      if bb[1].checked
      or bb[2].checked
      or bb[3].checked
      or bb[4].checked then
        for i := 1 to integer(StrToInt(ff[4].text)) do
          ff[5].text := ff[5].text + RandomWord(
              integer(StrToInt(ff[2].text)),
              bb[1].checked,
              bb[2].checked,
              bb[3].checked,
              bb[4].checked
            ) + #13;
    end;
     
    procedure TButton.onRelease;
    begin
      DrawButton(
        $D0D0D0,
        $E0E0E0,
        $808080,
        integer(caption._width),
        integer(caption._height)
      );
    end;
     
    var
      i: integer;
      b: TButton;
      f: TextFormat;
     
    begin
      for i := Low(bb) to High(bb) do
      begin
        bb[i] := TCheckBox.Create(_root);
        with bb[i] do
          SetBounds(10, 30 * i - 20, 530, 21);
      end;
      bb[1].Caption := 'Inclure des chiffres (0..9).';
      bb[2].Caption := 'Inclure des lettres majuscules (A..Z).';
      bb[3].Caption := 'Inclure des lettres minuscules (a..z).';
      bb[4].Caption := 'Inclure des caract'"è"'res sp'"é"'ciaux (' + S + ').';
      bb[1].checked := TRUE;
      bb[3].checked := TRUE;
     
      f := textFormat.Create('Arial', 12);
     
      ff[1] := TextField.Create(_root, '', 4, 10, 130, 480, 21);
      ff[1].SetNewTextFormat(f);
      ff[1].Text := 'Nombre de caract'"è"'res souhait'"é"'s: ';
      ff[3] := TextField.Create(_root, '', 5, 10, 160, 480, 21);
      ff[3].SetNewTextFormat(f);
      ff[3].Text := 'Nombre de mots de passe '"à"' g'"é"'n'"é"'rer: ';
     
      ff[2] := TextField.Create(_root, '', 6, 500, 130, 30, 21);
      ff[2].SetNewTextFormat(f);
      ff[2].type := 'input';
      ff[2].border := TRUE;
      ff[2].text := '12';
     
      ff[4] := TextField.Create(_root, '', 7, 500, 160, 30, 21);
      ff[4].SetNewTextFormat(f);
      ff[4].type := 'input';
      ff[4].border := TRUE;
      ff[4].text := '10';
     
      ff[5] := TextField.Create(_root, '', 8, 10, 190, 520, 160);
      ff[5].SetNewTextFormat(f);
      ff[5].border := TRUE;
     
      b := TButton.Create(195, 360, 150, 30, 'G'"é"'n'"é"'rer');
    end.
    Fichiers attachés Fichiers attachés
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  2. #2
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 430
    Points
    28 430
    Par défaut
    sympa
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  3. #3
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 070
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 070
    Points : 15 454
    Points
    15 454
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    sympa
    Merci Paul !

    Voici une version légèrement améliorée, qui permet de modifier la liste des caractères spéciaux à inclure.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
     
    (*----------------------------------------------------------------------------*)
    (* FlashPascal 2                                                              *)
    (* Générateur de mot de passe                                                 *)
    (* FlashCL : http://flashpascal.execute.re/FlashCL.php                        *)
    (*----------------------------------------------------------------------------*)
     
    program Generateur;
     
    {$FRAME_WIDTH 540}
    {$FRAME_HEIGHT 400}
     
    uses
      Flash8, Classes, Controls, StdCtrls;
     
    const
      L = 'abcdefghijklmnopqrstuvwxyz';
      C = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      D = '0123456789';
     
    var
      S: string;
     
    function RandomWord(
      aLength: integer;
      aDigits: boolean;
      aCapitals: boolean;
      aLowerChars: boolean;
      aSpecialChars: boolean): string;
    var
      a: array[1..4]of integer;
      i: integer;
    begin
      i := 0;
      if aDigits then
      begin
        Inc(i);
        a[i] := 1;
      end;
      if aCapitals then
      begin
        Inc(i);
        a[i] := 2;
      end;
      if aLowerChars then
      begin
        Inc(i);
        a[i] := 3;
      end;
      if aSpecialChars then
      begin
        Inc(i);
        a[i] := 4;
      end;
      result := '';
      if i > 0 then
        while Length(result) < aLength do
          case a[Trunc(i * Random + 1)] of
            1: result := result + D[Trunc(10 * Random + 1)];
            2: result := result + C[Trunc(26 * Random + 1)];
            3: result := result + L[Trunc(26 * Random + 1)];
            4: result := result + S[Trunc(Length(S) * Random + 1)];
          end;
    end;
     
    var
      bb: array[1..4] of TCheckBox;
      ff: array[1..6] of TextField;
     
    type
      TCustomButton = class(MovieClip)
        caption: TextField;
        procedure DrawButton(backColor, topColor, bottomColor, width, height: integer);
      end;
      TButton = class(TCustomButton)
        constructor Create(left, top, width, height: integer; aCaption: string);
        procedure doClick;
        procedure onRelease; override;
      end;
     
    { TCustomButton }
     
    procedure TCustomButton.DrawButton(
      backColor,
      topColor,
      bottomColor,
      width,
      height: integer
    );
    begin
      BeginFill(backColor);
      LineStyle(1, topColor);
      MoveTo(0, height);
      LineTo(0, 0);
      LineTo(width, 0);
      LineStyle(1, bottomColor);
      LineTo(width, height);
      LineTo(0, height);
      EndFill;
    end;
     
    { TButton }
     
    constructor TButton.Create(left, top, width, height: integer; aCaption: string);
    var
      f: textFormat;
    begin
      inherited Create(nil, '', GetNextHighestDepth());
      _x := left;
      _y := top;
      DrawButton($D0D0D0, $E0E0E0, $808080, width, height);
      caption := TextField.Create(
        self,
        '',
        GetNextHighestDepth(),
        0,
        5,
        width,
        height
      );
      caption.text := aCaption;
      f := TextFormat.Create('Arial', 12);
      f.align := 'center';
      caption.SetTextFormat(0, Length(caption.text), f);
      onPress := doClick;
    end;
     
    procedure TButton.doClick;
    var
      i: integer;
    begin
      DrawButton(
        $C0C0C0,
        $808080,
        $E0E0E0,
        integer(caption._width),
        integer(caption._height)
      );
     
      ff[5].text := '';
      S := ff[6].text;
     
      if bb[1].checked
      or bb[2].checked
      or bb[3].checked
      or bb[4].checked then
        for i := 1 to integer(StrToInt(ff[4].text)) do
          ff[5].text := ff[5].text + RandomWord(
              integer(StrToInt(ff[2].text)),
              bb[1].checked,
              bb[2].checked,
              bb[3].checked,
              bb[4].checked
            ) + #13;
    end;
     
    procedure TButton.onRelease;
    begin
      DrawButton(
        $D0D0D0,
        $E0E0E0,
        $808080,
        integer(caption._width),
        integer(caption._height)
      );
    end;
     
    var
      i: integer;
      b: TButton;
      f: TextFormat;
     
    begin
      for i := Low(bb) to High(bb) do
      begin
        bb[i] := TCheckBox.Create(_root);
        with bb[i] do
          SetBounds(10, 30 * i - 20, 530, 21);
      end;
      bb[1].Caption := 'Inclure des chiffres';
      bb[2].Caption := 'Inclure des lettres majuscules';
      bb[3].Caption := 'Inclure des lettres minuscules';
      bb[4].Caption := 'Inclure des caract'"è"'res sp'"é"'ciaux :';
      bb[1].checked := TRUE;
      bb[3].checked := TRUE;
     
      f := textFormat.Create('Arial', 12);
     
      ff[1] := TextField.Create(_root, '', 4, 10, 130, 480, 21);
      ff[1].SetNewTextFormat(f);
      ff[1].Text := 'Nombre de caract'"è"'res souhait'"é"'s :';
      ff[3] := TextField.Create(_root, '', 5, 10, 160, 480, 21);
      ff[3].SetNewTextFormat(f);
      ff[3].Text := 'Nombre de mots de passe '"à"' g'"é"'n'"é"'rer :';
     
      ff[2] := TextField.Create(_root, '', 6, 500, 130, 30, 21);
      ff[2].SetNewTextFormat(f);
      ff[2].type := 'input';
      ff[2].border := TRUE;
      ff[2].text := '12';
     
      ff[4] := TextField.Create(_root, '', 7, 500, 160, 30, 21);
      ff[4].SetNewTextFormat(f);
      ff[4].type := 'input';
      ff[4].border := TRUE;
      ff[4].text := '10';
     
      ff[6] := TextField.Create(_root, '', 9, 330, 100, 200, 21);
      ff[6].SetNewTextFormat(f);
      ff[6].type := 'input';
      ff[6].border := TRUE;
      ff[6].text := '!#$%&()*+,-./:;<=>?@[\]^_{|}~';
     
      ff[5] := TextField.Create(_root, '', 8, 10, 190, 520, 160);
      ff[5].SetNewTextFormat(f);
      ff[5].border := TRUE;
     
      b := TButton.Create(195, 360, 150, 30, 'G'"é"'n'"é"'rer');
    end.
    Au fait, pourrais-tu me rafraîchir la mémoire sur un point : à quoi sert la chaîne passée en second argument à la méthode Create des objets MovieClip et TextField ? J'ai remarqué que si je la laisse vide, cela n'empêche pas le programme de fonctionner.
    Fichiers attachés Fichiers attachés
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  4. #4
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Salut Rolland

    En fait, si je puis me permettre, Paul a adapté la méthode createEmptymovieclip d'as2 avec laquelle on crée une instance de movieclip et cette méthode reçoit entre autre comme paramètre name qui est le nom de cette instance. container: MovieClip=this.createEmptymovieclip("container",.....)
    Pour textfield, c'est un peu la même chose : movieclip possède la méthode createTextField qui reçoit le paramètre instancename qui est le nom de l'instance du textField.

    Paul a adapté ça à la manière d'as3 ou du langage pascal avec des méthodes constructeur propres

    exemple as3: montext:TextField= new TextField()
    mc:MovieClip= new Movieclip()

    a+

  5. #5
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 070
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 070
    Points : 15 454
    Points
    15 454
    Billets dans le blog
    9
    Par défaut
    Bonsoir Anthony !

    Content de te lire. Merci pour ta réponse. Il faudrait que je me mette un peu à ActionScript. Mais je me demande à quoi elle peut servir (ou plutôt comment elle peut servir) cette chaîne, en FlashPascal ? Je ne me souviens pas d'un exemple où elle était effectivement utilisée.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  6. #6
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 430
    Points
    28 430
    Par défaut
    hello,

    alors en FlashPascal le nom ne sert pas à grand chose en fait, mais en AS2 il permet de retrouver le composant ... ce doit être possible sous FlashPascal en passant par des variants d'ailleurs

    par contre, il y a des fonctions d'AS2 qui ne fonctionnent pas si le composant n'a pas de nom, j'ai découvert cela avec FlashPascal 0.4 le 25 Juillet 2008 !
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

Discussions similaires

  1. Votre avis sur ce code - Générateur de mot de passe
    Par austin57 dans le forum Tkinter
    Réponses: 4
    Dernier message: 22/09/2012, 23h34
  2. Générateur de Mot de Passe
    Par forum dans le forum Téléchargements
    Réponses: 0
    Dernier message: 03/06/2011, 16h32
  3. générateur de mot de passe
    Par cyborgtun dans le forum VB.NET
    Réponses: 0
    Dernier message: 19/05/2010, 21h10
  4. générateur de mot de passe
    Par zais_ethael dans le forum API standards et tierces
    Réponses: 1
    Dernier message: 18/05/2006, 15h47
  5. Générateur de mot de passe
    Par christel1982 dans le forum ASP
    Réponses: 2
    Dernier message: 16/11/2005, 12h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo