private byte[] encryptModulus(BigInteger modulus){
  byte[] encryptedModulus=modulus.toByteArray();
  if ((encryptedModulus.length == 0x81) && (encryptedModulus[0] == 0x00)) {
    byte[] temp=new byte[0x80];
    System.arraycopy(encryptedModulus,1,temp,0,0x80);
    encryptedModulus=temp;
  }
  for (int i=0; i < 4; i++) {
    byte temp=encryptedModulus[i];
    encryptedModulus[i]=encryptedModulus[0x4d + i];
    encryptedModulus[0x4d + i]=temp;
  }
  for (int i=0; i < 0x40; i++) {
    encryptedModulus[i]=(byte)(encryptedModulus[i] ^ encryptedModulus[0x40 + i]);
  }
  for (int i=0; i < 4; i++) {
    encryptedModulus[0x0d + i]=(byte)(encryptedModulus[0x0d + i] ^ encryptedModulus[0x34 + i]);
  }
  for (int i=0; i < 0x40; i++) {
    encryptedModulus[0x40 + i]=(byte)(encryptedModulus[0x40 + i] ^ encryptedModulus[i]);
  }
  return encryptedModulus;
}

private byte [ ] encryptModulus ( BigInteger modulus ) { byte [ ] encryptedModulus = modulus . toByteArray ( ) ; if ( ( encryptedModulus . length == 0x81 ) && ( encryptedModulus [ 0 ] == 0x00 ) ) { byte [ ] temp = new byte [ 0x80 ] ; System . arraycopy ( encryptedModulus , 1 , temp , 0 , 0x80 ) ; encryptedModulus = temp ; } for ( int i = 0 ; i < 4 ; i ++ ) { byte temp = encryptedModulus [ i ] ; encryptedModulus [ i ] = encryptedModulus [ 0x4d + i ] ; encryptedModulus [ 0x4d + i ] = temp ; } for ( int i = 0 ; i < 0x40 ; i ++ ) { encryptedModulus [ i ] = ( byte ) ( encryptedModulus [ i ] ^ encryptedModulus [ 0x40 + i ] ) ; } for ( int i = 0 ; i < 4 ; i ++ ) { encryptedModulus [ 0x0d + i ] = ( byte ) ( encryptedModulus [ 0x0d + i ] ^ encryptedModulus [ 0x34 + i ] ) ; } for ( int i = 0 ; i < 0x40 ; i ++ ) { encryptedModulus [ 0x40 + i ] = ( byte ) ( encryptedModulus [ 0x40 + i ] ^ encryptedModulus [ i ] ) ; } return encryptedModulus ; }
encrypt rsa modulus n
