怎么用Delphi对生成的ini文件进行乱码加密?

解决方案 »

  1.   

    ////////////////////////////////////字符串加密////////////////////////////////////function Encrypt(const str: string): string;
    var
      i, j, iKey        : Integer;
      strGet            : string;
    begin
      strGet := str;
      iKey := FKey;
      Result := strGet;
      for i := 1 to Length(strGet) do
      begin
        Result[i] := Char(byte(strGet[i]) xor (iKey shr 8));
        iKey := (Byte(Result[I]) + iKey) * FSeedA + FSeedB;
      end;
      strGet := Result;
      Result := '';
      for i := 1 to Length(strGet) do
      begin
        j := Integer(strGet[i]);
        Result := Result + Char(65 + (j div 26)) + char(65 + (j mod 26));
      end;
    end;
    ////////////////////////////////////字符串加密////////////////////////////////////
    ////////////////////////////////////字符串解密////////////////////////////////////function Decrypt(const str: string): string;
    var
      i, j, iKey        : Integer;
      strGet            : string;
    begin
      strGet := str;
      iKey := FKey;
      Result := '';
      for i := 1 to (Length(strGet) div 2) do
      begin
        j := (Integer(strGet[2 * i - 1]) - 65) * 26;
        j := j + (Integer(strGet[2 * i]) - 65);
        Result := Result + Char(j);
      end;
      strGet := Result;
      for i := 1 to Length(strGet) do
      begin
        Result[i] := Char(byte(strGet[I]) xor (iKey shr 8));
        iKey := (Byte(strGet[I]) + iKey) * FSeedA + FSeedB;
      end;
    end;
    ////////////////////////////////////字符串解密////////////////////////////////////
      

  2.   

    我再问明白点吧,有没有办法将ini文件里的所有内容赋值给字符串型的变量?我是想先把他们赋值给一个字符串型的变量,然后再用一定的规则(具体规则是我的机密)给它处以乱码加密,把乱码再写回ini文件!关键就是怎么把ini文件中的所有内容赋值给字符串型的变量,我想这只是一个语法问题而已!
      

  3.   

     直接把INI文件當成一個文本來讀就行了 Memo1.lines.loadFromFile('1.ini')