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;
一個簡易的加解密字符串函數
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.