加密字符串函数
function EncryptString(src: String; Key: String): string;
var
KeyLen: Integer;
KeyPos: Integer;
Offset: Integer;
dest: String;
SrcPos: Integer;
SrcAsc: Integer;
Range: Integer;
IntTemp: Integer;
SrcAnsi: PAnsiChar;
begin
KeyLen := Length(Key);
KeyPos := 0;
Range := 1;
Randomize;
Offset := Random(Range);
dest := Format('%1.2x', [Offset]);
SrcAnsi := PAnsiChar(AnsiString(src));
IntTemp := Length(SrcAnsi);
for SrcPos := 1 to IntTemp do
begin
SrcAsc := (Ord(SrcAnsi[SrcPos - 1]) + Offset) MOD 255;
if KeyPos < KeyLen then
KeyPos := KeyPos + 1
else
KeyPos := 1;
SrcAsc := SrcAsc xor Ord(Key[KeyPos]);
dest := dest + Format('%1.2x', [SrcAsc]);
Offset := SrcAsc;
end;
Result := dest;
end;
无
《学习大师原创文档,请勿转载,侵权必究》