Advertisement
Skygen

Cesar ALGORITHM

Nov 10th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.92 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Memo1: TMemo;
  12.     Memo2: TMemo;
  13.     Button1: TButton;
  14.     Button2: TButton;
  15.     procedure Button1Click(Sender: TObject);
  16.     procedure Button2Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.dfm}
  29.  
  30. function cEcezar(s:string;key:byte):string;
  31. var i:integer; c,d:char;
  32. begin
  33.   for i:=1 to length(s) do
  34.   begin
  35.     c:=s[i];
  36.     if not (c in [#10, #13]) then
  37.       d:=chr((ord(c)+ key)mod 255)
  38.     else d := c;
  39.     Result:=Result+d;
  40.   end;
  41. end;
  42.  
  43. procedure TForm1.Button1Click(Sender: TObject);
  44. begin
  45.   Memo2.Text := cEcezar(Memo1.Text, 3);
  46. end;
  47.  
  48. procedure TForm1.Button2Click(Sender: TObject);
  49. begin
  50.   Close;
  51. end;
  52.  
  53. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement