# EncryptionConfig (/zh-CN/api-reference/rtc/cpp-all-platforms/class-encryptionconfig)
> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).
```cpp
struct EncryptionConfig {
ENCRYPTION_MODE encryptionMode;
const char* encryptionKey;
uint8_t encryptionKdfSalt[32];
bool datastreamEncryptionEnabled;
const char* getEncryptionString() const;
};
```
## 属性 [#属性]
内置加密模式,详见 [ENCRYPTION_MODE](/zh-CN/api-reference/rtc/cpp-all-platforms/enum-encryptionmode)。声网建议使用 `AES_128_GCM2` 或 `AES_256_GCM2` 模式,这两种模式支持使用加密盐以提升安全性。
字符串类型的加密密钥,长度不受限制。声网建议使用 32 字节的密钥。
:::note
注: 如果未设置加密密钥或将其设置为 NULL,则无法使用内置加密,SDK 会返回 `-2`。
:::
用于加密的盐值,长度为 32 字节。
:::note
注: 该参数仅在 `AES_128_GCM2` 或 `AES_256_GCM2` 加密模式下生效。在此情况下,请确保该参数不为 `0`。
:::
是否启用数据流加密:
- true:启用数据流加密。
- false:(默认)禁用数据流加密。