enableEncryption method Null safety

Future<int> enableEncryption(
  1. bool enable,
  2. NERtcEncryptionConfig config
)

Enable or disable media stream encryption.

In scenarios with high security requirements such as finance, you can use this method to set the media stream encryption mode before you join the room.

You must call this method before you join a room. The encryption mode and key cannot be edited after you join a room. After you leave the room, the SDK will automatically turn off encryption. If you need to turn on encryption again, you need to call this method before you join the room again. In the same room, all users who enable media stream encryption must use the same encryption mode and key. Otherwise, an ENGINE_ERROR_ENCRYPT_NOT_SUITABLE (30113) error occurs if members in the room have different keys. For security purposes, we recommend that you replace with a new key every time the media stream encryption is enabled.

Implementation

Future<int> enableEncryption(
    bool enable, NERtcEncryptionConfig config) async {
  IntValue reply = await _api.enableEncryption(EnableEncryptionRequest()
    ..enable = enable
    ..key = config.key
    ..mode = config.mode.index);
  return reply.value ?? -1;
}