(* ----------
Code :
---------- *)
function XorStr(Stri, Strk: String): String;
var
Longkey: string;
I: Integer;
Next: char;
begin
for i := 0 to (Length(Stri) div Length(Strk)) do
Longkey := Longkey + Strk;
for I := 1 to length(Stri) do
begin
Next := chr((ord(Stri[i]) xor ord(Longkey[i])));
Result := Result + Next;
end;
end;
(* ---------------
Example:
--------------- *)
procedure TForm1.Button1Click(Sender: TObject);
begin
{ Encode The String }
Edit1.Text := XorStr('The String', '1234567890');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
{ Decode The String }
Edit2.Text := XorStr(Edit1.Text, '1234567890');
end;
Share:
These icons link to social bookmarking sites where readers can share and discover new web pages.
