title: Initial bytes incorrect after Java AES/CBC decryption
body: <p>What's wrong with the following example?</p>
  
  <p>The problem is that the first part of the decrypted string is nonsense. However, the rest is fine, I get...</p>
  
  <blockquote>
  <pre><code>Result: `£eB6O�geS��i are you? Have a nice day.
  </code></pre>
  </blockquote>
  
  <pre><code>@Test
  public void testEncrypt() {
    try {
      String s = "Hello there. How are you? Have a nice day.";
  
      // Generate key
      KeyGenerator kgen = KeyGenerator.getInstance("AES");
      kgen.init(128);
      SecretKey aesKey = kgen.generateKey();
  
      // Encrypt cipher
      Cipher encryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
      encryptCipher.init(Cipher.ENCRYPT_MODE, aesKey);
  
      // Encrypt
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      CipherOutputStream cipherOutputStream = new CipherOutputStream(outputStream, encryptCipher);
      cipherOutputStream.write(s.getBytes());
      cipherOutputStream.flush();
      cipherOutputStream.close();
      byte[] encryptedBytes = outputStream.toByteArray();
  
      // Decrypt cipher
      Cipher decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
      IvParameterSpec ivParameterSpec = new IvParameterSpec(aesKey.getEncoded());
      decryptCipher.init(Cipher.DECRYPT_MODE, aesKey, ivParameterSpec);
  
      // Decrypt
      outputStream = new ByteArrayOutputStream();
      ByteArrayInputStream inStream = new ByteArrayInputStream(encryptedBytes);
      CipherInputStream cipherInputStream = new CipherInputStream(inStream, decryptCipher);
      byte[] buf = new byte[1024];
      int bytesRead;
      while ((bytesRead = cipherInputStream.read(buf)) &gt;= 0) {
          outputStream.write(buf, 0, bytesRead);
      }
  
      System.out.println("Result: " + new String(outputStream.toByteArray()));
  
    } 
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }
  </code></pre>