function StrDecrypt(s: string; key: word): string;
var
i:byte;
const
fc1=1;
fc2=2;
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 4));
key:=(byte(result[i])+key)*fc1+fc2;
end;
end;
function StrEncrypt(s: string; key: word): string;
var
i:byte;
const
fc1=1;
fc2=2;
begin
setlength(result,length(s));
for i:=1 to length(s) do begin
result[i]:=char(byte(s[i])xor(key shr 4));
key:=(byte(s[i])+key)*fc1+fc2;
end;
end;
一个简易的加解密字符串函数
最新推荐文章于 2021-05-17 01:53:00 发布