//前面定义好常量
const
C1 = 123456;
C2 = 234567;
PASSKEY = '66666';
//加密函数
function Encrypt(const S: String; Key: Word): String;
var
I: byte;
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 Decrypt(const S: String; Key: Word): String;
var
I: byte;
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;
//使用方法------------------------------------------------
tmp := Encrypt('需要加密的内容', StrToInt(PASSKEY));
tmp := Decrypt('需要解密的内容', StrToInt(PASSKEY));
转载于:https://www.cnblogs.com/piaoliuxia/archive/2008/10/16/1937285.html
5181

被折叠的 条评论
为什么被折叠?



