code: public static byte[] encrypt(byte[] keyData, byte[] iv, byte[] data,
              String cipherTransformation)
              throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException,
              IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
          Cipher cipher = createCipher(Cipher.ENCRYPT_MODE, keyData, iv, cipherTransformation);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          try {
              byte[] temp = cipher.update(data);
              if (temp != null && temp.length > 0) {
                  baos.write(temp);
              }
              if (cipherTransformation.endsWith("/ECB/NoPadding")
                      || cipherTransformation.endsWith("/CBC/NoPadding")
                      || cipherTransformation.endsWith("/PCBC/NoPadding")) {
                  temp = cipher.doFinal(PADDING[16 - data.length % 16]);
              } else {
                  temp = cipher.doFinal();
              }
              if (temp != null && temp.length > 0) {
                  baos.write(temp);
              }
          } catch (IOException e) {
              throw new RuntimeException(e);
          }
          return baos.toByteArray();
      }
docs: Encrypt data using AES.
  
  @param keyData
  @param iv
  initial vector. If {@code null} or empty, {@link #DEFAULT_IV}
  will be used.
  @param data
  @param cipherTransformation
  cipher-transformation to use. If empty, {@link #DEFAULT_CIPHER_TRANSFORMATION}
  will be used.
  @return
  @throws NoSuchPaddingException
  @throws NoSuchAlgorithmException
  @throws InvalidKeyException
  @throws BadPaddingException
  @throws IllegalBlockSizeException
  @throws InvalidAlgorithmParameterException