docs: def encrypt(self, key, data, mode, padding):
          # this can be disabled by _disable_encryption, so pylint: disable=method-hidden
          """Encrypt data using the supplied values.
  
          :param bytes key: Loaded encryption key
          :param bytes data: Data to encrypt
          :param JavaMode mode: Encryption mode to use
          :param JavaPadding padding: Padding mode to use
          :returns: IV prepended to encrypted data
          :rtype: bytes
          """
          try:
              block_size = self.cipher.block_size
              iv_len = block_size // 8
              iv = os.urandom(iv_len)
  
              encryptor = Cipher(self.cipher(key), mode.build(iv), backend=default_backend()).encryptor()
              padder = padding.build(block_size).padder()
  
              padded_data = padder.update(data) + padder.finalize()
              return iv + encryptor.update(padded_data) + encryptor.finalize()
          except Exception:
              error_message = "Encryption failed"
              _LOGGER.exception(error_message)
              raise EncryptionError(error_message)