code: def aes_encrypt(mode, aes_key, aes_iv, *data):
      
      encryptor = Cipher(
          algorithms.AES(aes_key),
          mode(aes_iv),
          backend=default_backend()).encryptor()
  
      result = None
      for value in data:
          result = encryptor.update(value)
      encryptor.finalize()
  
      return result, None if not hasattr(encryptor, 'tag') else encryptor.tag
docs: Encrypt data with AES in specified mode.