unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  LCLTranslator, Classes, SysUtils, FileUtil, Forms, Controls, Graphics,
  Dialogs, StdCtrls, ComCtrls, ExtCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    TrackBar1: TTrackBar;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure TrackBar1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private

  public

  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}
function PasswortErzeugen(Laenge: Integer): string;
var
AlleZeichen, Passwort: String;
Position, Zaehler: Integer;
begin
   AlleZeichen:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?-_%&$';
   Passwort:= '';
   Randomize;
   for Zaehler:= 1 to Laenge do
   begin
      Position:= Random(Length(AlleZeichen)) + 1;
      // copy -> String, Position_im_String, Länge
      Passwort := Passwort + copy (AlleZeichen, Position, 1);
   end;
   Result:= Passwort;
end;

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text:= PasswortErzeugen(Trackbar1.Position);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   Edit1.Text:= LowerCase(PasswortErzeugen(Trackbar1.Position));
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
   Edit1.Text:= UpperCase(PasswortErzeugen(Trackbar1.Position));
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Label2.Caption:= IntToStr(Trackbar1.Position);
end;

procedure TForm1.TrackBar1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Label2.Caption:= IntToStr(Trackbar1.Position);
end;


end.

