Генератор паролей

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by S1nteZ, 4 Jun 2007.

  1. S1nteZ

    S1nteZ Banned

    Joined:
    4 Jun 2007
    Messages:
    3
    Likes Received:
    4
    Reputations:
    -2
    Я тут написал генератор паролей.Думаю для примера сойдёт. Прога вроде простая, но если возникнут вопросы пишите, я добавлю коментарии. Сдесь EXE файл _files.adamant.ua/3362
    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, Spin;

    type
    TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    CheckBox6: TCheckBox;
    Button2: TButton;
    SaveDialog1: TSaveDialog;
    Button3: TButton;
    SpinEdit1: TSpinEdit;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;
    buf:string;
    implementation
    const
    cifri: array [1..10] of char =('1','2','3','4','5','6','7','8','9','0');
    symbol: array [1..17] of char =('<','>','@','!','(',')','-','?','[',']','+','{','}',',','.','=','*');
    RusL: array [1..33] of char =('й','ц','у','к','е','н','г','ш','щ','з','х','ъ', 'ф','ы','в','а','п',
    'р','о','л','д','ж','э','я','ч','с','м','и','т','ь ','б','ю','ё');
    RusB: array [1..33] of char =('Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ', 'Ф','Ы','В','А','П',
    'Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь ','Б','Ю','Ё');
    EngL: array [1..26] of char =('q','w','e','r','t','y','u','i','o','p','a','s', 'd','f','g','h','j',
    'k','l','z','x','c','v','b','n','m');
    EngB: array [1..26] of char =('Q','W','E','R','T','Y','U','I','O','P','A','S', 'D','F','G','H','J',
    'K','L','Z','X','C','V','B','N','M');
    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    var
    i,n,c:integer;
    begin
    buf:='';
    randomize;
    n:=SpinEdit1.Value;
    i:=1;
    repeat
    c:=random(6);
    If (c=0) and (CheckBox1.Checked) then
    begin
    buf:=buf+cifri[random(9)+1];
    i:=i+1;
    end else
    If (c=1) and (CheckBox2.Checked) then
    begin
    buf:=buf+symbol[random(16)+1];
    i:=i+1;
    end;
    If (c=2) and (CheckBox3.Checked) then
    begin
    buf:=buf+RusL[random(32)+1];
    i:=i+1;
    end;
    If (c=3) and (CheckBox4.Checked) then
    begin
    buf:=buf+RusB[random(32)+1];
    i:=i+1;
    end;
    If (c=4) and (CheckBox5.Checked) then
    begin
    buf:=buf+EngL[random(25)+1];
    i:=i+1;
    end;
    If (c=5) and (CheckBox6.Checked) then
    begin
    buf:=buf+EngB[random(25)+1];
    i:=i+1;
    end;
    until i=n+1;
    Label1.Caption:=buf;
    end;

    procedure TForm1.Button2Click(Sender: TObject);
    var
    f:TextFile;
    fname:String;
    begin
    If SaveDialog1.Execute then
    begin
    fname:=SaveDialog1.Filename;
    AssignFile(f,fname);
    Rewrite(f);
    Write(f,buf);
    CloseFile(f);
    end;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    SaveDialog1.Filter:='Текст|*.txt';
    SaveDialog1.FileName:='*.txt';
    end;

    procedure TForm1.Button3Click(Sender: TObject);
    begin
    Form1.Close;
    end;

    end.
     
    1 person likes this.
  2. zl0y

    zl0y Banned

    Joined:
    13 Sep 2006
    Messages:
    371
    Likes Received:
    270
    Reputations:
    109
    я уже выладывал и код там был немного проще =) пользы нету!
     
  3. _Nikolas_

    _Nikolas_ New Member

    Joined:
    27 Dec 2006
    Messages:
    17
    Likes Received:
    3
    Reputations:
    0
    Баш как всегда рулит :)

    Code:
    pass=`dd status=noxfer ibs=1 count=8 if=/dev/urandom | base64`; echo ${pass%=}
    Для особо мнительных можно заменить на /dev/random и подвигать мышкой, тогда пасс точно будет случайный :)