function XorEncode(const Key, Source: string): string;
var
I: Integer;
C: Byte;
begin
Result := '';
for I := 1 to Length(Source) do begin
if Length(Key) > 0 then
C := Byte(Key[1 + ((I - 1) mod Length(Key))]) xor Byte(Source[I])
else
C := Byte(Source[I]);
Result := Result + AnsiLowerCase(IntToHex(C, 2));
end;
end;
function XorDecode(const Key, Source: string): string;
var
I: Integer;
C: Char;
begin
Result := '';
for I := 0 to Length(Source) div 2 - 1 do begin
C := Chr(StrToIntDef('$' + Copy(Source, (I * 2) + 1, 2), Ord(' ')));
if Length(Key) > 0 then
C := Chr(Byte(Key[1 + (I mod Length(Key))]) xor Byte(C));
Result := Result + C;
end;
end;
function encode(s:string):string;
{///////////简单的字符串加密涵数////////////////////////////}
{///////////输入参数:字符串;输出差数:字符串/////////////////}
{///////////2003-7-15 ///////////////}
var
n,i:integer;
str:string;
begin
n:=length(s);
str:='';
for i:=1 to n do
begin
str:=str+char(ord(s[i])-1);
end;
encode:=str;
end;
function decode(s:string):string;
{///////////简单的字符串解密涵数////////////////////////////}
{///////////输入参数:字符串;输出差数:字符串/////////////////}
{///////////2003-7-15 ///////////////}
var
n,i:integer;
str:string;
begin
n:=length(s);
str:='';
for i:=1 to n do
begin
str:=str+char(ord(s[i])+1);
end;
decode:=str;
end;