//安全与保密函数 编号:0020
//------------------------------------------------------------------------------------------
//利用异或和移位进行的快速加密和解密,加密强度不高,但是速度很快
//possible variations is 2^96
//It is kinda slow: 137K File = Encrypt 0.267sec Decrypt 0.265sec
// 3,198M File = Encrypt 6.541 sec Decrypt 6.374sec
// (Includes reading source and writing result.
// Figures generated on a P100, 32 megs ram).
// Memory Encrypt More Speed up!
//change the constants to WORD values of your choice (preferably over 256).
//
const C1 = 52845;
const C2 = 22719;
function _FastEncrypt(const S: String; Key: Word): String;
var
I: Integer;
begin
Result := S;
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 _FastDecrypt(const S: String; Key: Word): String;
var
I: Integer;
begin
Result := S;
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;