function ptom(const s:string;key:word):string;
var
i:byte;
begin
//result[0]:=s[0];
setlength(result,length(s));
for i:=1 to length(s) do
begin
result[i]:=char(byte(s[i])xor (key shr 8));
key:=(byte(result[i])+ key)*fc1+fc2;
end;
end;
function mtop(const s:string;key:word):string;
var
i:byte;
begin
setlength(result,length(s));
for i:=1 to length(s) do begin
result[i]:=char(byte(s[i])xor(key shr 8));
key:=(byte(s[i])+key)*fc1+fc2;
end;
end;
短字符串的简单加密/解密 [摘录]
const
c1 = 52845;
c2 = 22719;
function Encrypt (const s: string; Key: Word) : string;
var
i : byte;
begin
Result[0] := s[0];
for i := 1 to length (s) do
begin
Result[i] := Char (byte (s[i]) xor (Key shr 8));
Key := (byte (Result[i]) + Key) * c1 + c2
end
end;
function Decrypt (const s: string; Key: Word) : string;
var
i : byte;
begin
Result[0] := s[0];
for i := 1 to length (s) do
begin
Result[i] := Char (byte (s[i]) xor (Key shr 8));
Key := (byte (s[i]) + Key) * c1 + c2
end
end;
function EncryptOrUnEncryptfiles(FileName: string;jor:boolean):boolean;
var
iFileHandle: Integer;
iFileLength: Integer;
Buffer: PChar;
i : integer;
cflag:boolean;
key:integer;
newfilename:string;
begin
if not fileexists(filename) then //若文件不存在则返回
begin
result:=false;
exit;
end;