FEncryptionConfig
配置内置加密模式和密钥。
C++
USTRUCT(BlueprintType)
struct FEncryptionConfig
{
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|EncryptionConfig")
EENCRYPTION_MODE encryptionMode = EENCRYPTION_MODE::AES_128_GCM;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|EncryptionConfig")
FString encryptionKey = "";
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|EncryptionConfig")
FString encryptionKdfSalt = "";
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|EncryptionConfig")
bool datastreamEncryptionEnabled = false;
FEncryptionConfig(){}
FEncryptionConfig(const agora::rtc::EncryptionConfig & AgoraData){
encryptionMode = static_cast<EENCRYPTION_MODE>(AgoraData.encryptionMode);
encryptionKey = UTF8_TO_TCHAR(AgoraData.encryptionKey);
char valencryptionKdfSalt[32] = {0};
int AgoraCount = 32;
for (int i = 0; i < AgoraCount; i++) {
encryptionKdfSalt[i] = AgoraData.encryptionKdfSalt[i];
}
encryptionKdfSalt = valencryptionKdfSalt;
datastreamEncryptionEnabled = AgoraData.datastreamEncryptionEnabled;
}
agora::rtc::EncryptionConfig CreateAgoraData() const {
agora::rtc::EncryptionConfig AgoraData;
AgoraData.encryptionMode = static_cast<agora::rtc::ENCRYPTION_MODE>(encryptionMode);
SET_UABT_FSTRING_TO_CONST_CHAR___MEMALLOC(AgoraData.encryptionKey,this->encryptionKey)
std::string StdencryptionKdfSalt = TCHAR_TO_UTF8(*encryptionKdfSalt);
int AgoraCount = 32;
for (int i = 0; i < AgoraCount; i++) {
if(i >= StdencryptionKdfSalt.size()){
break;
}
AgoraData.encryptionKdfSalt[i] = StdencryptionKdfSalt[i];
}
AgoraData.datastreamEncryptionEnabled = datastreamEncryptionEnabled;
return AgoraData;
}
void FreeAgoraData(agora::rtc::EncryptionConfig & AgoraData) const {
SET_UABT_FSTRING_TO_CONST_CHAR___MEMFREE(AgoraData.encryptionKey)
}
};
encryptionMode
内置加密模式。详见 EENCRYPTION_MODE。建议使用 AES_128_GCM2
或 AES_256_GCM2
加密模式。这两种模式支持使用盐,安全性更高。
encryptionKey
内置加密密钥,字符串类型,长度无限制。建议使用 32 字节的密钥。
注意
如果未指定该参数或将该参数设置为
NULL
,则无法启用内置加密,且 SDK 会返回错误码 -2
。encryptionKdfSalt
盐,长度为 32 字节。建议你在服务端使用 OpenSSL 生成盐。
注意
只有在
AES_128_GCM2
或 AES_256_GCM2
加密模式下,该参数才生效。此时,需确保填入该参数的值不全为 0
。datastreamEncryptionEnabled
是否开启数据流加密:
true
:开启数据流加密。false
:(默认)关闭数据流加密。