在DELPHI:
procedure initPermutation(var inData: array of Byte);
var
  newData: array[0..7] of Byte;
  i: Integer;
begin
  FillChar(newData, 8, 0);
  for i := 0 to 63 do
    if (inData[BitIP[i] shr 3] and (1 shl (7- (BitIP[i] and $07)))) <> 0 then
      newData[i shr 3] := newData[i shr 3] or (1 shl (7-(i and $07)));
  for i := 0 to 7 do inData[i] := newData[i];
end;
转为JAVA怎样写?

解决方案 »

  1.   

    public void initPermutation(byte[] inData) {
      byte[] newData = new byte[8]; //默认已经是零
        for ( int i = 0; i <= 63; i++) {
          if ((inData[BitIP[i] >>> 3] && (1 << (7 - (BitIP[i] & 7)))) != 0 ) {
             newData[i >>> 3] = (byte)(newData[i >>>3] | (1 << (7 - (i & 7))));
          }
        }
        for (int i = 0; i <=7; i++) {
          inData[i] = newData[i];
        }

    }
      

  2.   

    public void initPermutation(byte[] inData) {
      byte[] newData = new byte[8]; //默认已经是零
        for ( int i = 0; i <= 63; i++) {
          if ((inData[BitIP[i] >>> 3] & (1 << (7 - (BitIP[i] & 7)))) != 0 ) {
             newData[i >>> 3] = (byte)(newData[i >>>3] | (1 << (7 - (i & 7))));
          }
        }
        for (int i = 0; i <=7; i++) {
          inData[i] = newData[i];
        }
    }取掉 if 中间的 "&"
      

  3.   

    好高手你已拿100分了还有100在这里请帮我解决吧谢谢。
    http://community.csdn.net/Expert/TopicView.asp?id=4031712