code: public static Cipher createCipher(int mode, byte[] keyData, byte[] iv,
              String cipherTransformation) throws NoSuchAlgorithmException, NoSuchPaddingException,
              InvalidKeyException, InvalidAlgorithmParameterException {
          if (StringUtils.isBlank(cipherTransformation)) {
              cipherTransformation = DEFAULT_CIPHER_TRANSFORMATION;
          }
          if (!cipherTransformation.startsWith("AES/ECB/")) {
              // non-ECB requires IV
              if (iv == null || iv.length == 0) {
                  iv = DEFAULT_IV_BYTES;
              }
          } else {
              // must not use IV with ECB
              iv = null;
          }
          SecretKeySpec aesKey = new SecretKeySpec(keyData, CIPHER_ALGORITHM);
          Cipher cipher = Cipher.getInstance(cipherTransformation);
          if (iv == null) {
              cipher.init(mode, aesKey);
          } else {
              AlgorithmParameterSpec spec = cipherTransformation.startsWith("AES/GCM/")
                      ? new GCMParameterSpec(128, iv)
                      : new IvParameterSpec(iv);
              cipher.init(mode, aesKey, spec);
          }
          return cipher;
      }
docs: Create and initialize a {@link Cipher} instance.
  
  @param mode
  either {@link Cipher#ENCRYPT_MODE} or {@link Cipher#DECRYPT_MODE}
  @param keyData
  @param iv
  @param cipherTransformation
  @return
  @throws NoSuchPaddingException
  @throws NoSuchAlgorithmException
  @throws InvalidKeyException
  @throws InvalidAlgorithmParameterException
  @since 0.9.2