title: Java cipher behaves diffrently on diffrent Envirements
body: <p>i have coded a netty server-client system with encryption but if i use the programm on my laptop it dosent work, there is no error so i dont know where the problem is, My Encryption utils class:</p>
  
  <pre><code>public static ByteBuf decryptWithRSA(ByteBuf encrypted, PrivateKey mykey) throws Exception {
      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.DECRYPT_MODE, mykey);
      return wrightbytes(encrypted.alloc().buffer(), cipher.doFinal(readbytes(encrypted))); 
  }
  
  public static ByteBuf encryptWithRSA(ByteBuf encrypted, PublicKey mykey) throws Exception {
      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.ENCRYPT_MODE, mykey);
      return wrightbytes(encrypted.alloc().buffer(), cipher.doFinal(readbytes(encrypted))); 
  }
  
  
  
  
  
  
  public static ByteBuf encryptWithAES(SecretKey key, ByteBuf message) throws Exception  {
      Cipher cipher = Cipher.getInstance("AES");
      cipher.init(Cipher.ENCRYPT_MODE, key);
      return wrightbytes(message.alloc().buffer(), cipher.doFinal(readbytes(message)));
  }
  
  public static ByteBuf dycryptWithAES(SecretKey key, ByteBuf message) throws Exception {
      Cipher cipher = Cipher.getInstance("AES");
      cipher.init(Cipher.DECRYPT_MODE, key);
      return wrightbytes(message.alloc().buffer(), cipher.doFinal(readbytes(message)));
  }
  
  public static SecretKey generateAESKey(int size) throws NoSuchAlgorithmException {
       KeyGenerator kgen = KeyGenerator.getInstance("AES");
          kgen.init(size);
          return kgen.generateKey();
  }
  
  private static ByteBuf wrightbytes(ByteBuf wright, byte[] data) {
      int i = 0;
      while (i &lt; data.length) {
          wright.writeByte(data[i]);
          i++;
      }
      return wright;
  }
  
  private static byte[] readbytes(ByteBuf buf) {
      int read = buf.readableBytes();
      byte[] data = new byte[read];
      int i = buf.readerIndex();
      while (i &lt; read) {
          data[i] = buf.readByte();
          i++;
      }
      return data;
  }
  </code></pre>
  
  <p>Maybe anywone spots a bug i dident get? Thats for youre help</p>