Security Encryption
Feature Overview
This feature can be used to encrypt stream information to protect communication security.
Developers can encrypt streams when publishing. For encrypted streams, when playing, developers need to provide a decryption key that matches the encryption key, otherwise the stream cannot be successfully played.
Download Example Source Code
Please refer to Download Example Source Code to get the source code.
For related source code, please check the files in the "/ZegoExpressExample/Examples/Others/Security" directory.
Prerequisites
Before using the security encryption feature, ensure that:
- ZEGO Express SDK has been integrated into your project and basic video call functions have been implemented. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
- A project has been created in the ZEGOCLOUD Console and valid AppID and AppSign have been obtained. For details, please refer to Console - Project Management.
Usage Steps
1 Set Publishing Stream Encryption Key
Call setPublishStreamEncryptionKey to set the publishing stream encryption key. This interface can be called before or after publishing the stream.
-
This interface is only valid when publishing to the Zego RTC server.
-
It supports calling setPublishStreamEncryptionKey during publishing to update the encryption key. Note that the playing stream's decryption key must be updated first before updating the publishing stream's encryption key, otherwise the stream playing will fail.
-
Calling stopPublishingStream or logoutRoom will clear the encryption key.
// key is the encryption key, only supports lengths of 16/24/32 bytes.
engine->setPublishStreamEncryptionKey(key);2 Set Playing Stream Decryption Key
Call setPlayStreamDecryptionKey to set the playing stream decryption key. This interface can be called before or after playing the stream.
- This interface is only valid when playing from the Zego RTC or L3 server.
- It supports calling setPlayStreamDecryptionKey during playing to update the decryption key. Note that the playing stream's decryption key must be updated first before updating the publishing stream's encryption key, otherwise the stream playing will fail.
- Calling stopPlayingStream or logoutRoom will clear the encryption key.
// playStreamID is the playing stream ID
// key is the decryption key, only supports lengths of 16/24/32 bytes.
engine->setPlayStreamDecryptionKey(playStreamID,key);Start Publishing and Playing Streams
Please refer to Quick Start - Implementation to complete the publishing and playing stream operations in sequence.
API Reference List
| Method | Description |
|---|---|
| setPublishStreamEncryptionKey | Set publishing stream encryption key |
| setPlayStreamDecryptionKey | Set playing stream decryption key |
