我做了一个字符串加密解密的函数,(强度?知道算法就没有强度),
加密后还是字符串 Ascii($21..$7e) -> Ascii($21..$7e)
function SecuText(const T: ShortString
Key: Integer): ShortString;
var R: ShortString;
I, L: Integer;
N: array[1..255] of Integer;
begin
R := '';
L := Length(T);
if L < 2 then Result := T else
begin
for I := 1 to L do N := Byte(T) - 32;
N[L] := (N[L] + Key) mod 95;
N[1] := (N[L] + N[1]) mod 95;
for I := 2 to L do N:=(Key + N[I - 1] + N) mod 95;
for I := 1 to L do
begin
R := R + Char(32 + N);
end;
Result := R;
end;
end;
function OpenText(const T: ShortString
Key: Integer): ShortString;
var
R: ShortString;
I, L: Integer;
N: array [1..255] of Integer;
begin
R := '';
L := Length(T);
if L < 2 then Result := T else
begin
for I := 1 to L do N := Byte(T) - 32;
for I := L downto 2 do N := (N + 95 - Key + 95 - N[I - 1]) mod 95;
N[1] := (N[1] + (95 - N[L])) mod 95;
N[L] := (N[L] + (95 - Key)) mod 95;
for I := 1 to L do R := R + Char(N + 32);
Result := R;
end;
end;