This site uses cookies own and third. If you continue to browse consider to accept the use of cookies. OK More Info.

[Delphi] DH String Generator 0.3

  • 0 Replies
  • 4182 Views

0 Members and 1 Guest are viewing this topic.

Offline BigBear

  • *
  • Underc0der
  • Posts: 541
  • Actividad:
    0%
  • Reputación 3
    • View Profile

[Delphi] DH String Generator 0.3

  • on: June 10, 2016, 12:12:00 pm
Un programa en Delphi para generar strings de 10 tipos diferentes y longitudes especificas.

Una imagen :



El codigo :

Code: (delphi) You are not allowed to view links. Register or Login
// DH String Generator 0.3
// (C) Doddy Hackman 2016

unit generator;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Math, Vcl.ExtCtrls,
  Vcl.ComCtrls, Vcl.Imaging.pngimage, Vcl.ImgList, FormAbout;

type
  TFormHome = class(TForm)
    imgLogo: TImage;
    gbStrings: TGroupBox;
    txtString1: TEdit;
    btnGen1: TButton;
    btnCopy1: TButton;
    txtString2: TEdit;
    txtString3: TEdit;
    btnGen2: TButton;
    btnCopy2: TButton;
    btnGen3: TButton;
    btnCopy3: TButton;
    txtString4: TEdit;
    btnGen4: TButton;
    btnCopy4: TButton;
    txtString5: TEdit;
    btnGen5: TButton;
    btnCopy5: TButton;
    txtString6: TEdit;
    btnGen6: TButton;
    btnCopy6: TButton;
    txtString7: TEdit;
    btnGen7: TButton;
    btnCopy7: TButton;
    txtString8: TEdit;
    btnGen8: TButton;
    btnCopy8: TButton;
    txtString9: TEdit;
    btnGen9: TButton;
    btnCopy9: TButton;
    txtString10: TEdit;
    btnGen10: TButton;
    btnCopy10: TButton;
    gbEnterLength: TGroupBox;
    gbOptions: TGroupBox;
    btnAutomatic: TButton;
    btnAbout: TButton;
    btnExit: TButton;
    txtLength: TEdit;
    udLength: TUpDown;
    automatic_string: TTimer;
    ilIconos: TImageList;
    procedure btnGen1Click(Sender: TObject);
    procedure btnGen2Click(Sender: TObject);
    procedure btnGen3Click(Sender: TObject);
    procedure btnGen4Click(Sender: TObject);
    procedure btnGen5Click(Sender: TObject);
    procedure btnGen6Click(Sender: TObject);
    procedure btnGen7Click(Sender: TObject);
    procedure btnGen8Click(Sender: TObject);
    procedure btnGen9Click(Sender: TObject);
    procedure btnGen10Click(Sender: TObject);
    procedure btnCopy1Click(Sender: TObject);
    procedure btnCopy2Click(Sender: TObject);
    procedure btnCopy3Click(Sender: TObject);
    procedure btnCopy4Click(Sender: TObject);
    procedure btnCopy5Click(Sender: TObject);
    procedure btnCopy6Click(Sender: TObject);
    procedure btnCopy7Click(Sender: TObject);
    procedure btnCopy8Click(Sender: TObject);
    procedure btnCopy9Click(Sender: TObject);
    procedure btnCopy10Click(Sender: TObject);
    procedure automatic_stringTimer(Sender: TObject);
    procedure btnAutomaticClick(Sender: TObject);
    procedure btnAboutClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormHome: TFormHome;

implementation

{$R *.dfm}
// Functions

function dh_generate_string(option: string; length_string: integer): string;
const
  letters1: array [1 .. 26] of string = ('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');
const
  letters2: array [1 .. 26] of string = ('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');
const
  numbers: array [1 .. 10] of string = ('0', '1', '2', '3', '4', '5', '6', '7',
    '8', '9');

const
  cyrillic: array [1 .. 44] of string = ('?', '?', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '?', '?');

const
  no_idea1: array [1 .. 13] of string = ('?', '?', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '?');

const
  no_idea2: array [1 .. 28] of string = ('?', '?', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '?', '?', '?', '?', '??', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '??');

const
  no_idea3: array [1 .. 13] of string = ('??', '?', '?', '?', '?', '?', '?',
    '_', '?', '`', '?', '_', '?');

const
  no_idea4: array [1 .. 26] of string = ('?', '?', '€', '?', 'l', '?', '™', 'O',
    'e', '?', '?', '?', '?', '?', '?', '?', '?', '-', '/', '·', 'v', '8', '?',
    '˜', '?', '=');

const
  no_idea5: array [1 .. 33] of string = ('?', '?', '?', '?', 'n', '?', '?', '?',
    '?', '?', '?', 'G', '?', '?', '?', 'e', 'ß', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '?', '?', '?', '8', 'S', '?');

const
  no_idea6: array [1 .. 32] of string = ('?', '?', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
    '?', '?', '?', '?', '?', '?', '?', '?', '?');
var
  code: string;
  gen_now: string;
  i: integer;
  index: integer;
begin

  gen_now := '';

  for i := 1 to length_string do
  begin
    if (option = '1') then
    begin
      gen_now := gen_now + letters1[RandomRange(1, Length(letters1) + 1)];
    end
    else if (option = '2') then
    begin
      gen_now := gen_now + letters2[RandomRange(1, Length(letters2) + 1)];
    end
    else if (option = '3') then
    begin
      gen_now := gen_now + numbers[RandomRange(1, Length(numbers) + 1)];
    end
    else if (option = '4') then
    begin
      gen_now := gen_now + cyrillic[RandomRange(1, Length(cyrillic) + 1)];
    end
    else if (option = '5') then
    begin
      gen_now := gen_now + no_idea1[RandomRange(1, Length(no_idea1) + 1)];
    end
    else if (option = '6') then
    begin
      gen_now := gen_now + no_idea2[RandomRange(1, Length(no_idea2) + 1)];
    end
    else if (option = '7') then
    begin
      gen_now := gen_now + no_idea3[RandomRange(1, Length(no_idea3) + 1)];
    end
    else if (option = '8') then
    begin
      gen_now := gen_now + no_idea4[RandomRange(1, Length(no_idea4) + 1)];
    end
    else if (option = '9') then
    begin
      gen_now := gen_now + no_idea5[RandomRange(1, Length(no_idea5) + 1)];
    end
    else if (option = '10') then
    begin
      gen_now := gen_now + no_idea6[RandomRange(1, Length(no_idea6) + 1)];
    end
    else
    begin
      gen_now := gen_now + letters1[RandomRange(1, Length(letters1) + 1)];
    end;
  end;
  code := gen_now;

  Result := code;
end;

function message_box(title, message_text, type_message: string): string;
begin
  if not(title = '') and not(message_text = '') and not(type_message = '') then
  begin
    try
      begin
        if (type_message = 'Information') then
        begin
          MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
            MB_ICONINFORMATION);
        end
        else if (type_message = 'Warning') then
        begin
          MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
            MB_ICONWARNING);
        end
        else if (type_message = 'Question') then
        begin
          MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
            MB_ICONQUESTION);
        end
        else if (type_message = 'Error') then
        begin
          MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
            MB_ICONERROR);
        end
        else
        begin
          MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
            MB_ICONINFORMATION);
        end;
        Result := '[+] MessageBox : OK';
      end;
    except
      begin
        Result := '[-] Error';
      end;
    end;
  end
  else
  begin
    Result := '[-] Error';
  end;
end;

//

procedure TFormHome.btnGen1Click(Sender: TObject);
begin
  txtString1.Text := dh_generate_string('1', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen2Click(Sender: TObject);
begin
  txtString2.Text := dh_generate_string('2', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen3Click(Sender: TObject);
begin
  txtString3.Text := dh_generate_string('3', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen4Click(Sender: TObject);
begin
  txtString4.Text := dh_generate_string('4', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen5Click(Sender: TObject);
begin
  txtString5.Text := dh_generate_string('5', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen6Click(Sender: TObject);
begin
  txtString6.Text := dh_generate_string('6', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen7Click(Sender: TObject);
begin
  txtString7.Text := dh_generate_string('7', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen8Click(Sender: TObject);
begin
  txtString8.Text := dh_generate_string('8', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen9Click(Sender: TObject);
begin
  txtString9.Text := dh_generate_string('9', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnGen10Click(Sender: TObject);
begin
  txtString10.Text := dh_generate_string('10', StrToInt(txtLength.Text));
end;

procedure TFormHome.btnCopy1Click(Sender: TObject);
begin
  if not(txtString1.Text = '') then
  begin
    txtString1.SelectAll;
    txtString1.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy2Click(Sender: TObject);
begin
  if not(txtString2.Text = '') then
  begin
    txtString2.SelectAll;
    txtString2.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy3Click(Sender: TObject);
begin
  if not(txtString3.Text = '') then
  begin
    txtString3.SelectAll;
    txtString3.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy4Click(Sender: TObject);
begin
  if not(txtString4.Text = '') then
  begin
    txtString4.SelectAll;
    txtString4.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy5Click(Sender: TObject);
begin
  if not(txtString5.Text = '') then
  begin
    txtString5.SelectAll;
    txtString5.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy6Click(Sender: TObject);
begin
  if not(txtString6.Text = '') then
  begin
    txtString6.SelectAll;
    txtString6.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy7Click(Sender: TObject);
begin
  if not(txtString7.Text = '') then
  begin
    txtString7.SelectAll;
    txtString7.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy8Click(Sender: TObject);
begin
  if not(txtString8.Text = '') then
  begin
    txtString8.SelectAll;
    txtString8.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy9Click(Sender: TObject);
begin
  if not(txtString9.Text = '') then
  begin
    txtString9.SelectAll;
    txtString9.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnCopy10Click(Sender: TObject);
begin
  if not(txtString10.Text = '') then
  begin
    txtString10.SelectAll;
    txtString10.CopyToClipboard;
    message_box('DH String Generator 0.3', 'String copied to the clipboard',
      'Information');
  end
  else
  begin
    message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  end;
end;

procedure TFormHome.btnAboutClick(Sender: TObject);
begin
  FormAbout.frmAbout.Show();
end;

procedure TFormHome.btnAutomaticClick(Sender: TObject);
begin
  if (automatic_string.Enabled = False) then
  begin
    btnAutomatic.Caption := 'Disable Automatic Generate';
    automatic_string.Enabled := True;
  end
  else
  begin
    btnAutomatic.Caption := 'Enable Automatic Generate';
    automatic_string.Enabled := False;
  end;
end;

procedure TFormHome.automatic_stringTimer(Sender: TObject);
begin
  txtString1.Text := dh_generate_string('1', StrToInt(txtLength.Text));
  txtString2.Text := dh_generate_string('2', StrToInt(txtLength.Text));
  txtString3.Text := dh_generate_string('3', StrToInt(txtLength.Text));
  txtString4.Text := dh_generate_string('4', StrToInt(txtLength.Text));
  txtString5.Text := dh_generate_string('5', StrToInt(txtLength.Text));
  txtString6.Text := dh_generate_string('6', StrToInt(txtLength.Text));
  txtString7.Text := dh_generate_string('7', StrToInt(txtLength.Text));
  txtString8.Text := dh_generate_string('8', StrToInt(txtLength.Text));
  txtString9.Text := dh_generate_string('9', StrToInt(txtLength.Text));
  txtString10.Text := dh_generate_string('10', StrToInt(txtLength.Text));
end;

end.

// The End ?

Si quieren bajar el programa lo pueden hacer de aca :

You are not allowed to view links. Register or Login.
You are not allowed to view links. Register or Login.

Eso seria todo.