comment
IRC Chat
play_arrow
Este sitio utiliza cookies propias y de terceros. Si continúa navegando consideramos que acepta el uso de cookies. OK Más Información.

[Delphi] DH String Generator 0.3

  • 0 Respuestas
  • 1564 Vistas

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado BigBear

  • *
  • Underc0der
  • Mensajes: 543
  • Actividad:
    0%
  • Reputación 3
    • Ver Perfil
« en: Junio 10, 2016, 12:12:00 pm »
Un programa en Delphi para generar strings de 10 tipos diferentes y longitudes especificas.

Una imagen :



El codigo :

Código: Delphi
  1. // DH String Generator 0.3
  2. // (C) Doddy Hackman 2016
  3.  
  4. unit generator;
  5.  
  6. interface
  7.  
  8. uses
  9.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  10.   System.Classes, Vcl.Graphics,
  11.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Math, Vcl.ExtCtrls,
  12.   Vcl.ComCtrls, Vcl.Imaging.pngimage, Vcl.ImgList, FormAbout;
  13.  
  14. type
  15.   TFormHome = class(TForm)
  16.     imgLogo: TImage;
  17.     gbStrings: TGroupBox;
  18.     txtString1: TEdit;
  19.     btnGen1: TButton;
  20.     btnCopy1: TButton;
  21.     txtString2: TEdit;
  22.     txtString3: TEdit;
  23.     btnGen2: TButton;
  24.     btnCopy2: TButton;
  25.     btnGen3: TButton;
  26.     btnCopy3: TButton;
  27.     txtString4: TEdit;
  28.     btnGen4: TButton;
  29.     btnCopy4: TButton;
  30.     txtString5: TEdit;
  31.     btnGen5: TButton;
  32.     btnCopy5: TButton;
  33.     txtString6: TEdit;
  34.     btnGen6: TButton;
  35.     btnCopy6: TButton;
  36.     txtString7: TEdit;
  37.     btnGen7: TButton;
  38.     btnCopy7: TButton;
  39.     txtString8: TEdit;
  40.     btnGen8: TButton;
  41.     btnCopy8: TButton;
  42.     txtString9: TEdit;
  43.     btnGen9: TButton;
  44.     btnCopy9: TButton;
  45.     txtString10: TEdit;
  46.     btnGen10: TButton;
  47.     btnCopy10: TButton;
  48.     gbEnterLength: TGroupBox;
  49.     gbOptions: TGroupBox;
  50.     btnAutomatic: TButton;
  51.     btnAbout: TButton;
  52.     btnExit: TButton;
  53.     txtLength: TEdit;
  54.     udLength: TUpDown;
  55.     automatic_string: TTimer;
  56.     ilIconos: TImageList;
  57.     procedure btnGen1Click(Sender: TObject);
  58.     procedure btnGen2Click(Sender: TObject);
  59.     procedure btnGen3Click(Sender: TObject);
  60.     procedure btnGen4Click(Sender: TObject);
  61.     procedure btnGen5Click(Sender: TObject);
  62.     procedure btnGen6Click(Sender: TObject);
  63.     procedure btnGen7Click(Sender: TObject);
  64.     procedure btnGen8Click(Sender: TObject);
  65.     procedure btnGen9Click(Sender: TObject);
  66.     procedure btnGen10Click(Sender: TObject);
  67.     procedure btnCopy1Click(Sender: TObject);
  68.     procedure btnCopy2Click(Sender: TObject);
  69.     procedure btnCopy3Click(Sender: TObject);
  70.     procedure btnCopy4Click(Sender: TObject);
  71.     procedure btnCopy5Click(Sender: TObject);
  72.     procedure btnCopy6Click(Sender: TObject);
  73.     procedure btnCopy7Click(Sender: TObject);
  74.     procedure btnCopy8Click(Sender: TObject);
  75.     procedure btnCopy9Click(Sender: TObject);
  76.     procedure btnCopy10Click(Sender: TObject);
  77.     procedure automatic_stringTimer(Sender: TObject);
  78.     procedure btnAutomaticClick(Sender: TObject);
  79.     procedure btnAboutClick(Sender: TObject);
  80.   private
  81.     { Private declarations }
  82.   public
  83.     { Public declarations }
  84.   end;
  85.  
  86. var
  87.   FormHome: TFormHome;
  88.  
  89. implementation
  90.  
  91. {$R *.dfm}
  92. // Functions
  93.  
  94. function dh_generate_string(option: string; length_string: integer): string;
  95. const
  96.   letters1: array [1 .. 26] of string = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
  97.     'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
  98.     'x', 'y', 'z');
  99. const
  100.   letters2: array [1 .. 26] of string = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
  101.     'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
  102.     'X', 'Y', 'Z');
  103. const
  104.   numbers: array [1 .. 10] of string = ('0', '1', '2', '3', '4', '5', '6', '7',
  105.     '8', '9');
  106.  
  107. const
  108.   cyrillic: array [1 .. 44] of string = ('?', '?', '?', '?', '?', '?', '?', '?',
  109.     '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
  110.     '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
  111.     '?', '?', '?', '?', '?', '?');
  112.  
  113. const
  114.   no_idea1: array [1 .. 13] of string = ('?', '?', '?', '?', '?', '?', '?', '?',
  115.     '?', '?', '?', '?', '?');
  116.  
  117. const
  118.   no_idea2: array [1 .. 28] of string = ('?', '?', '?', '?', '?', '?', '?', '?',
  119.     '?', '?', '?', '?', '?', '?', '?', '?', '??', '?', '?', '?', '?', '?', '?',
  120.     '?', '?', '?', '?', '??');
  121.  
  122. const
  123.   no_idea3: array [1 .. 13] of string = ('??', '?', '?', '?', '?', '?', '?',
  124.     '_', '?', '`', '?', '_', '?');
  125.  
  126. const
  127.   no_idea4: array [1 .. 26] of string = ('?', '?', '€', '?', 'l', '?', '™', 'O',
  128.     'e', '?', '?', '?', '?', '?', '?', '?', '?', '-', '/', '·', 'v', '8', '?',
  129.     '˜', '?', '=');
  130.  
  131. const
  132.   no_idea5: array [1 .. 33] of string = ('?', '?', '?', '?', 'n', '?', '?', '?',
  133.     '?', '?', '?', 'G', '?', '?', '?', 'e', 'ß', '?', '?', '?', '?', '?', '?',
  134.     '?', '?', '?', '?', '?', '?', '?', '8', 'S', '?');
  135.  
  136. const
  137.   no_idea6: array [1 .. 32] of string = ('?', '?', '?', '?', '?', '?', '?', '?',
  138.     '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
  139.     '?', '?', '?', '?', '?', '?', '?', '?', '?');
  140. var
  141.   code: string;
  142.   gen_now: string;
  143.   i: integer;
  144.   index: integer;
  145. begin
  146.  
  147.   gen_now := '';
  148.  
  149.   for i := 1 to length_string do
  150.   begin
  151.     if (option = '1') then
  152.     begin
  153.       gen_now := gen_now + letters1[RandomRange(1, Length(letters1) + 1)];
  154.     end
  155.     else if (option = '2') then
  156.     begin
  157.       gen_now := gen_now + letters2[RandomRange(1, Length(letters2) + 1)];
  158.     end
  159.     else if (option = '3') then
  160.     begin
  161.       gen_now := gen_now + numbers[RandomRange(1, Length(numbers) + 1)];
  162.     end
  163.     else if (option = '4') then
  164.     begin
  165.       gen_now := gen_now + cyrillic[RandomRange(1, Length(cyrillic) + 1)];
  166.     end
  167.     else if (option = '5') then
  168.     begin
  169.       gen_now := gen_now + no_idea1[RandomRange(1, Length(no_idea1) + 1)];
  170.     end
  171.     else if (option = '6') then
  172.     begin
  173.       gen_now := gen_now + no_idea2[RandomRange(1, Length(no_idea2) + 1)];
  174.     end
  175.     else if (option = '7') then
  176.     begin
  177.       gen_now := gen_now + no_idea3[RandomRange(1, Length(no_idea3) + 1)];
  178.     end
  179.     else if (option = '8') then
  180.     begin
  181.       gen_now := gen_now + no_idea4[RandomRange(1, Length(no_idea4) + 1)];
  182.     end
  183.     else if (option = '9') then
  184.     begin
  185.       gen_now := gen_now + no_idea5[RandomRange(1, Length(no_idea5) + 1)];
  186.     end
  187.     else if (option = '10') then
  188.     begin
  189.       gen_now := gen_now + no_idea6[RandomRange(1, Length(no_idea6) + 1)];
  190.     end
  191.     else
  192.     begin
  193.       gen_now := gen_now + letters1[RandomRange(1, Length(letters1) + 1)];
  194.     end;
  195.   end;
  196.   code := gen_now;
  197.  
  198.   Result := code;
  199. end;
  200.  
  201. function message_box(title, message_text, type_message: string): string;
  202. begin
  203.   if not(title = '') and not(message_text = '') and not(type_message = '') then
  204.   begin
  205.     try
  206.       begin
  207.         if (type_message = 'Information') then
  208.         begin
  209.           MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
  210.             MB_ICONINFORMATION);
  211.         end
  212.         else if (type_message = 'Warning') then
  213.         begin
  214.           MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
  215.             MB_ICONWARNING);
  216.         end
  217.         else if (type_message = 'Question') then
  218.         begin
  219.           MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
  220.             MB_ICONQUESTION);
  221.         end
  222.         else if (type_message = 'Error') then
  223.         begin
  224.           MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
  225.             MB_ICONERROR);
  226.         end
  227.         else
  228.         begin
  229.           MessageBox(FormHome.Handle, PChar(message_text), PChar(title),
  230.             MB_ICONINFORMATION);
  231.         end;
  232.         Result := '[+] MessageBox : OK';
  233.       end;
  234.     except
  235.       begin
  236.         Result := '[-] Error';
  237.       end;
  238.     end;
  239.   end
  240.   else
  241.   begin
  242.     Result := '[-] Error';
  243.   end;
  244. end;
  245.  
  246. //
  247.  
  248. procedure TFormHome.btnGen1Click(Sender: TObject);
  249. begin
  250.   txtString1.Text := dh_generate_string('1', StrToInt(txtLength.Text));
  251. end;
  252.  
  253. procedure TFormHome.btnGen2Click(Sender: TObject);
  254. begin
  255.   txtString2.Text := dh_generate_string('2', StrToInt(txtLength.Text));
  256. end;
  257.  
  258. procedure TFormHome.btnGen3Click(Sender: TObject);
  259. begin
  260.   txtString3.Text := dh_generate_string('3', StrToInt(txtLength.Text));
  261. end;
  262.  
  263. procedure TFormHome.btnGen4Click(Sender: TObject);
  264. begin
  265.   txtString4.Text := dh_generate_string('4', StrToInt(txtLength.Text));
  266. end;
  267.  
  268. procedure TFormHome.btnGen5Click(Sender: TObject);
  269. begin
  270.   txtString5.Text := dh_generate_string('5', StrToInt(txtLength.Text));
  271. end;
  272.  
  273. procedure TFormHome.btnGen6Click(Sender: TObject);
  274. begin
  275.   txtString6.Text := dh_generate_string('6', StrToInt(txtLength.Text));
  276. end;
  277.  
  278. procedure TFormHome.btnGen7Click(Sender: TObject);
  279. begin
  280.   txtString7.Text := dh_generate_string('7', StrToInt(txtLength.Text));
  281. end;
  282.  
  283. procedure TFormHome.btnGen8Click(Sender: TObject);
  284. begin
  285.   txtString8.Text := dh_generate_string('8', StrToInt(txtLength.Text));
  286. end;
  287.  
  288. procedure TFormHome.btnGen9Click(Sender: TObject);
  289. begin
  290.   txtString9.Text := dh_generate_string('9', StrToInt(txtLength.Text));
  291. end;
  292.  
  293. procedure TFormHome.btnGen10Click(Sender: TObject);
  294. begin
  295.   txtString10.Text := dh_generate_string('10', StrToInt(txtLength.Text));
  296. end;
  297.  
  298. procedure TFormHome.btnCopy1Click(Sender: TObject);
  299. begin
  300.   if not(txtString1.Text = '') then
  301.   begin
  302.     txtString1.SelectAll;
  303.     txtString1.CopyToClipboard;
  304.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  305.       'Information');
  306.   end
  307.   else
  308.   begin
  309.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  310.   end;
  311. end;
  312.  
  313. procedure TFormHome.btnCopy2Click(Sender: TObject);
  314. begin
  315.   if not(txtString2.Text = '') then
  316.   begin
  317.     txtString2.SelectAll;
  318.     txtString2.CopyToClipboard;
  319.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  320.       'Information');
  321.   end
  322.   else
  323.   begin
  324.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  325.   end;
  326. end;
  327.  
  328. procedure TFormHome.btnCopy3Click(Sender: TObject);
  329. begin
  330.   if not(txtString3.Text = '') then
  331.   begin
  332.     txtString3.SelectAll;
  333.     txtString3.CopyToClipboard;
  334.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  335.       'Information');
  336.   end
  337.   else
  338.   begin
  339.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  340.   end;
  341. end;
  342.  
  343. procedure TFormHome.btnCopy4Click(Sender: TObject);
  344. begin
  345.   if not(txtString4.Text = '') then
  346.   begin
  347.     txtString4.SelectAll;
  348.     txtString4.CopyToClipboard;
  349.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  350.       'Information');
  351.   end
  352.   else
  353.   begin
  354.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  355.   end;
  356. end;
  357.  
  358. procedure TFormHome.btnCopy5Click(Sender: TObject);
  359. begin
  360.   if not(txtString5.Text = '') then
  361.   begin
  362.     txtString5.SelectAll;
  363.     txtString5.CopyToClipboard;
  364.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  365.       'Information');
  366.   end
  367.   else
  368.   begin
  369.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  370.   end;
  371. end;
  372.  
  373. procedure TFormHome.btnCopy6Click(Sender: TObject);
  374. begin
  375.   if not(txtString6.Text = '') then
  376.   begin
  377.     txtString6.SelectAll;
  378.     txtString6.CopyToClipboard;
  379.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  380.       'Information');
  381.   end
  382.   else
  383.   begin
  384.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  385.   end;
  386. end;
  387.  
  388. procedure TFormHome.btnCopy7Click(Sender: TObject);
  389. begin
  390.   if not(txtString7.Text = '') then
  391.   begin
  392.     txtString7.SelectAll;
  393.     txtString7.CopyToClipboard;
  394.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  395.       'Information');
  396.   end
  397.   else
  398.   begin
  399.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  400.   end;
  401. end;
  402.  
  403. procedure TFormHome.btnCopy8Click(Sender: TObject);
  404. begin
  405.   if not(txtString8.Text = '') then
  406.   begin
  407.     txtString8.SelectAll;
  408.     txtString8.CopyToClipboard;
  409.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  410.       'Information');
  411.   end
  412.   else
  413.   begin
  414.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  415.   end;
  416. end;
  417.  
  418. procedure TFormHome.btnCopy9Click(Sender: TObject);
  419. begin
  420.   if not(txtString9.Text = '') then
  421.   begin
  422.     txtString9.SelectAll;
  423.     txtString9.CopyToClipboard;
  424.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  425.       'Information');
  426.   end
  427.   else
  428.   begin
  429.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  430.   end;
  431. end;
  432.  
  433. procedure TFormHome.btnCopy10Click(Sender: TObject);
  434. begin
  435.   if not(txtString10.Text = '') then
  436.   begin
  437.     txtString10.SelectAll;
  438.     txtString10.CopyToClipboard;
  439.     message_box('DH String Generator 0.3', 'String copied to the clipboard',
  440.       'Information');
  441.   end
  442.   else
  443.   begin
  444.     message_box('DH String Generator 0.3', 'String is empty', 'Warning');
  445.   end;
  446. end;
  447.  
  448. procedure TFormHome.btnAboutClick(Sender: TObject);
  449. begin
  450.   FormAbout.frmAbout.Show();
  451. end;
  452.  
  453. procedure TFormHome.btnAutomaticClick(Sender: TObject);
  454. begin
  455.   if (automatic_string.Enabled = False) then
  456.   begin
  457.     btnAutomatic.Caption := 'Disable Automatic Generate';
  458.     automatic_string.Enabled := True;
  459.   end
  460.   else
  461.   begin
  462.     btnAutomatic.Caption := 'Enable Automatic Generate';
  463.     automatic_string.Enabled := False;
  464.   end;
  465. end;
  466.  
  467. procedure TFormHome.automatic_stringTimer(Sender: TObject);
  468. begin
  469.   txtString1.Text := dh_generate_string('1', StrToInt(txtLength.Text));
  470.   txtString2.Text := dh_generate_string('2', StrToInt(txtLength.Text));
  471.   txtString3.Text := dh_generate_string('3', StrToInt(txtLength.Text));
  472.   txtString4.Text := dh_generate_string('4', StrToInt(txtLength.Text));
  473.   txtString5.Text := dh_generate_string('5', StrToInt(txtLength.Text));
  474.   txtString6.Text := dh_generate_string('6', StrToInt(txtLength.Text));
  475.   txtString7.Text := dh_generate_string('7', StrToInt(txtLength.Text));
  476.   txtString8.Text := dh_generate_string('8', StrToInt(txtLength.Text));
  477.   txtString9.Text := dh_generate_string('9', StrToInt(txtLength.Text));
  478.   txtString10.Text := dh_generate_string('10', StrToInt(txtLength.Text));
  479. end;
  480.  
  481. end.
  482.  
  483. // The End ?
  484.  

Si quieren bajar el programa lo pueden hacer de aca :

SourceForge.
Github.

Eso seria todo.

 

¿Te gustó el post? COMPARTILO!



[Sintaxis general de Delphi] By: Geek Lord Venezuela [R00t] Team

Iniciado por ANTRAX

Respuestas: 0
Vistas: 2055
Último mensaje Febrero 24, 2010, 04:35:15 pm
por ANTRAX
Eliminar acentos y otros agregados de un caracter/cadena Delphi 2009

Iniciado por ANTRAX

Respuestas: 0
Vistas: 3265
Último mensaje Febrero 24, 2010, 04:57:14 pm
por ANTRAX
1er troyano en Delphi By: Geek Lord Venezuela [R00t] Team

Iniciado por ANTRAX

Respuestas: 0
Vistas: 3512
Último mensaje Febrero 24, 2010, 04:34:48 pm
por ANTRAX
[Delphi] Creacion de un Troyano de conexion inversa

Iniciado por BigBear

Respuestas: 4
Vistas: 3794
Último mensaje Mayo 05, 2017, 09:10:55 am
por _inicio_cerrarsesión
Poner splash screen con progress bar en delphi

Iniciado por ANTRAX

Respuestas: 0
Vistas: 2987
Último mensaje Febrero 24, 2010, 04:54:23 pm
por ANTRAX