docs: 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);
          }
      }