Simple Encrypting and Decrypting a Text File

Hello guys back again to write code and the last my program need to backup and encrypt that file, for backup i'm using unidump that so easy just 1 line command, you can find it at google but result still showing true SQL statement. find, find and find now i found simple function encrypt decrypt a text file. here we go..

for function you can add this :
Function EncryptString(const sBuffer : Widestring) : Widestring;
var
i : Integer;
begin
Result := sBuffer;

for i:=1 to Length(sBuffer) do
Result[i] := Chr(23 XOr Ord(sBuffer[i]));
end;

Function DecryptString(const sBuffer : Widestring) : Widestring;
var
i :Integer;
begin
Result := sBuffer;

for i:=1 to Length(sBuffer) do
Result[i] := Chr(23 XOr Ord(sBuffer[i]));
end;

And next add this to button or whatever you want add.
//To Encrypt the file.
var
oSL : TStringlist;
begin
oSL := TStringlist.Create;
oSL.LoadFromFile('C:\Debug.txt');

oSL.Text := EncryptString(oSL.Text);

oSL.SaveToFile('C:\Debug.txt');

oSL.Free;


//To decrypt the file in RAM and read it.
var
i : Integer;
oSL : TStringlist;
begin
oSL := TStringlist.Create;
oSL.LoadFromFile('C:\Debug.txt');

oSL.Text := DecryptString(oSL.Text);

//Read the decrypted data from oSL.
for i:=0 to oSL.Count-1 do begin
Showmessage(oSL[i]);
end;

oSL.Free;