原来写了段加密解密算法来着
只是生成后有时是一些乱码!
谢谢!

解决方案 »

  1.   

    const
      C1 = 42845;  //加、解密因子一
      C2 = 16719;  //加、解密因子二function Encrypt(const S: string; Key: Word): string;
    var
      I: Integer;
    begin
      Result := S;
      for I := 1 to Length(S) do
      begin
        Result[I] := char(byte(S[I]) xor ((Key shr 8) and 127));
        Key := (byte(Result[I]) + Key) * C1 + C2;
      end;
    end;function Decrypt(const S: string; Key: Word): string;
    var
      I: Integer;
    begin
      Result := S;
      for I := 1 to Length(S) do
      begin
        Result[I] := char(byte(S[I]) xor ((Key shr 8) and 127));
        Key := (byte(S[I]) + Key) * C1 + C2;
      end;
    end;
    //解密时需使用跟加密一样的Key