code: protected byte[] encrypt(byte[] iv, byte[] data, SecretKey key, Cipher cipher) {
  
          // Basic null check.
          // An empty array can be encrypted:
          if (iv == null || data == null) {
              return null;
          }
  
          // Validate the initialisation vector:
          if (iv.length != getIvSize(cipher)) {
              throw new IllegalArgumentException("The supplied initialisation vector is the wrong size. Expected " + getIvSize(cipher) + " bytes but got " + iv.length + " bytes.");
          }
  
          // Prepare a cipher instance:
          initCipher(cipher, Cipher.ENCRYPT_MODE, key, iv);
  
          // Encrypt the data:
          try {
              return cipher.doFinal(data);
          } catch (IllegalBlockSizeException e) {
              throw new IllegalStateException("Block-size exception when completing encryption.", e);
          } catch (BadPaddingException e) {
              throw new IllegalStateException("Padding error detected when completing encryption.", e);
          }
      }
docs: This method encrypts a byte array. This is useful if you have raw binary
  data you need to encrypt.
  <p>
  To keep the interface simple, this method is marked as protected. The
  intention is that, if you need to encrypt byte arrays, you can subclass
  {@link Crypto} to expose this method.
  <p>
  This is the bread-and-butter of most encryption operations, but
  ultimately is a less common application-level use-case, because binary
  data is usually stream-based and the rest of the time it tends to be
  Strings you need to deal with. This is why it isn't exposed by default.
  
  @param iv   The initialisation vector.
  @param data The cleartext data.
  @param key  The key to be used to encrypt the data.
  @param cipher The {@link Cipher} instance to use.
  @return The encrypted data, or null if the given byte array is null. An
  empty array can be encrypted, but a null one cannot.
  @throws IllegalArgumentException If the given key is not a valid {@value #CIPHER_ALGORITHM}
  key.
  @see #decrypt(byte[], byte[], SecretKey, Cipher)