unit Verschlüsseln;
interface
uses
WinApi.Windows, System.SysUtils, System.Variants, System.Classes, Dialogs;
type
TChest =
class
private
{ Decode }
procedure MakeAlg(s:
string; slRes: TStringList);
function MakeAsc(sl: TStringList):
string;
function BuildAl(s: Integer; sch: Integer): Integer;
public
{ Encode / Decode }
function BuildSt(s:
string):
string;
end;
var
Chest: TChest;
implementation
function StringReverse(S:
String):
String;
var
i: Integer;
begin
Result:='
';
for i:=Length(S)
downto 1
do
Begin
Result:=Result+Copy(S,i,1);
end;
end;
procedure TChest.MakeAlg(s:
string; slRes: TStringList);
var
i: Integer;
begin
for i := 0
to length(s) - 1
do
begin
slRes.Add(IntToStr(Ord(s[i])));
end;
end;
function TChest.MakeAsc(sl: TStringList):
string;
var
i: Integer;
sRes:
string;
begin
sRes := '
';
for i := 0
to sl.Count - 1
do
begin
sRes := sRes + IntToStr(Chest.BuildAl(StrToInt(sl.Strings[i]), i)*Chest.BuildAl(StrToInt(StringReverse(sl.Strings[i])), i+8));
end;
Result := Trim(sRes);
end;
function TChest.BuildAl(s: Integer; sch: Integer): Integer;
var
i: Integer;
begin
i := s+(sch + 5916) * 5 + (sch + 356) * 3;
Result := i;
end;
function TChest.BuildSt(s:
string):
string;
var
sl: TStringList;
begin
sl := TStringList.Create;
try
Chest.MakeAlg(s, sl);
sl.Text := Chest.MakeAsc(sl);
Result := sl.Text;
finally
sl.Free;
end;
end;
end.