function
Encrypt_(s:
string
; EncodeTable:
array
of
Integer
):
string
;
var
i,KeyL:
Integer
;
begin
Result:=
''
;
KeyL:=
0
;
for
i:=
1
to
Length(s)
do
begin
if
KeyL>
2
then
KeyL:=
0
;
Result:=Result+
Char
(Ord(s[i])+EncodeTable[KeyL]);
Inc(KeyL);
end
;
end
;
function
Encrypt(s:
string
):
string
;
const
Key1:
array
[
0..2
]
of
Integer
=(
1
,
2
,
0
);
Key2:
array
[
0..2
]
of
Integer
=(
2
,
3
,
1
);
Key3:
array
[
0..2
]
of
Integer
=(
3
,
4
,
2
);
var
ParsSTR,NumT:
string
;
begin
Result:=
''
;
if
Length(s)<
4
then
Exit;
ParsSTR:=(Encrypt_(s,Key1));
NumT:=Copy(ParsSTR,
1
,Pos(
'-'
,ParsSTR)-
1
);
try
StrToInt(NumT);
Result:=
'"'
+Trim(ParsSTR)+
'"'
;
except
try
ParsSTR:=(Encrypt_(s,Key2));
NumT:=Copy(ParsSTR,
1
,Pos(
'-'
,ParsSTR)-
1
);
StrToInt(NumT);
Result:=
'"'
+Trim(ParsSTR)+
'"'
;
except
try
ParsSTR:=(Encrypt_(s,Key3));
NumT:=Copy(ParsSTR,
1
,Pos(
'-'
,ParsSTR)-
1
);
StrToInt(NumT);
Result:=
'"'
+Trim(ParsSTR)+
'"'
;
except
Result:=
'"Error: s1 '
+s[
1
]+
' s4 '
+s[
4
]+
'"'
;
end
;
end
;
end
;
end
;