this slowpoke moves

Ceasar String Crypter

var
  Form1: TForm1;
  chaine : integer;
  table_new_chr : array of char;
  
//

// Crypt String
procedure TForm1.Button1Click(Sender: TObject);
var
  u : integer;
  x_ascii, y_ascii : byte;
  c : char;

begin
  Memo2.Text := '';
  chaine := length(Memo1.text) + 2;
  SetLength(table_new_chr, chaine);

    for u := 1 to chaine - 1 do
    begin
    c := Memo1.text[u];
    x_ascii := ord(c);
    y_ascii := (x_ascii + StrToInt(Edit2.text)) mod 255;

        while y_ascii < 0 do
           begin
                y_ascii := y_ascii + 255;
           end;

    table_new_chr[u] := chr(y_ascii);
  end;
    for u := 1 to  chaine - 1 do
    begin
    Memo2.Text := Memo2.Text + table_new_chr[u];
    end;
end;

// Decrypt String
procedure TForm1.Button2Click(Sender: TObject);
var
  u : integer;
  x_ascii,y_ascii : byte;
  c : char;
begin
  Memo1.Text := '';
  chaine := length(Memo2.Text);
  SetLength(table_new_chr, chaine - 1);
  //Memo2.Text := Memo1.text;

  for u := 1 to chaine - 1 do
    begin
    c := Memo2.text[u];
    x_ascii := ord(c);
    y_ascii := (x_ascii - StrToInt(Edit2.text)) mod 255;

        while y_ascii < 0 do
           begin
                y_ascii := y_ascii + 255;
           end;

    table_new_chr[u] := chr(y_ascii);
  end;
    for u := 1 to  chaine - 1 do
    begin
    Memo1.Text := Memo1.Text + table_new_chr[u];
    end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate