title: Java cipher update method
body: <p>I'm trying to learn encoding in Java and stuck with Cipher.update() method. Does it have some maximum length of data it can update?
  Here is an example of what I'm speaking (I put "String s" value just to speed up process, this value goes through encryption and decryption process):</p>
  
  <pre><code>public class AES {
      public static String s = "long string";
  
      public byte [] encryptAES(byte[] data, byte[] keyPass) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, UnsupportedEncodingException {
  
          Cipher ciph = Cipher.getInstance("AES");
  
          SecretKeySpec AESkeySpec = new SecretKeySpec(keyPass, "AES");
          ciph.init(ENCRYPT_MODE,AESkeySpec);
  
          ciph.update(s.getBytes());
          byte[] encryptedData = ciph.doFinal();
  
          return encryptedData;
      }
  }
  </code></pre>
  
  <p>Output after decryption: <code>long string</code></p>
  
  <p>If I change value</p>
  
  <pre><code>public static String s = "long long long long long long long long long long long string";
  </code></pre>
  
  <p>output after decoding will be: <code>g long string</code></p>
  
  <p>And if after I take out <code>.update()</code> method and perform encryption like</p>
  
  <pre><code>Cipher ciph = Cipher.getInstance("AES");
  
  SecretKeySpec AESkeySpec = new SecretKeySpec(keyPass, "AES");
  ciph.init(ENCRYPT_MODE,AESkeySpec);
  //ciph.update(s.getBytes());
  
  byte[] encryptedData = ciph.doFinal(s.getBytes());
  return encryptedData;
  </code></pre>
  
  <p>I will get expected output like: <code>long long long long long long long long long long long string</code></p>
  
  <p>Why does it happen like that?</p>