如何实现这样一个函数 每字节异或3e,然后高四位与低四位交换顺序谢谢

解决方案 »

  1.   

    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));
               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));
               Key := (byte(S[I]) + Key) * C1 + C2;
          end;
      end;