# EnableEncryptionEx (/zh-CN/api-reference/rtc/csharp-windows/api-irtcengineex-enableencryptionex) > For AI agents: see the complete documentation index at [llms.txt](/llms.txt). ```csharp public abstract int EnableEncryptionEx(RtcConnection connection, bool enabled, EncryptionConfig config); ``` 用户离开频道后,SDK 会自动关闭加密。如需重新开启加密,你需要在用户再次加入频道前调用该方法。 ## 适用场景 [#适用场景] 对安全要求较高的场景。 ## 调用时机 [#调用时机] 该方法需要在加入频道前调用。 ## 调用限制 [#调用限制] - 同一频道内的所有用户在调用该方法时,必须设置相同的加密模式和密钥。 - 如果开启了内置加密,则不能使用旁路推流功能。 ## 参数 [#参数] 是否开启内置加密: - true: 开启内置加密。 - false:(默认)关闭内置加密。 配置内置加密模式和密钥。详见 [EncryptionConfig](/zh-CN/api-reference/rtc/csharp-windows/class-encryptionconfig)。 Connection 信息。详见 [RtcConnection](/zh-CN/api-reference/rtc/csharp-windows/class-rtcconnection)。 ## 返回值 [#返回值] ### 所属接口类 [#所属接口类] - [IRtcEngineEx](/zh-CN/api-reference/rtc/csharp-windows/rtc-interface-class#class_irtcengineex)