EncryptionConfig

  • Flutter

更新时间不可用

配置内置加密模式和密钥。

Dart
@JsonSerializable(explicitToJson: true, includeIfNull: false)
class EncryptionConfig {
  const EncryptionConfig(
      {this.encryptionMode,
      this.encryptionKey,
      this.encryptionKdfSalt,
      this.datastreamEncryptionEnabled});

  @JsonKey(name: 'encryptionMode')
  final EncryptionMode? encryptionMode;

  @JsonKey(name: 'encryptionKey')
  final String? encryptionKey;

  @JsonKey(name: 'encryptionKdfSalt', ignore: true)
  final Uint8List? encryptionKdfSalt;

  @JsonKey(name: 'datastreamEncryptionEnabled')
  final bool? datastreamEncryptionEnabled;

  factory EncryptionConfig.fromJson(Map<String, dynamic> json) =>
      _$EncryptionConfigFromJson(json);

  Map<String, dynamic> toJson() => _$EncryptionConfigToJson(this);
}

属性

参数名描述
encryptionMode

内置加密模式。详见 EncryptionMode。建议使用 aes128Gcm2 或 aes256Gcm2 加密模式。这两种模式支持使用盐,安全性更高。

encryptionKey

内置加密密钥,字符串类型,长度无限制。建议使用 32 字节的密钥。

注: 如果未指定该参数或将该参数设置为 NULL,则无法启用内置加密,且 SDK 会返回错误码 -2。

encryptionKdfSalt

盐,长度为 32 字节。建议你在服务端使用 OpenSSL 生成盐。

注: 只有在 aes128Gcm2 或 aes256Gcm2 加密模式下,该参数才生效。此时,需确保填入该参数的值不全为 0。

datastreamEncryptionEnabled

是否开启数据流加密:

  • true:开启数据流加密。
  • false:(默认)关闭数据流加密。
表格内容超出当前宽度,可横向滚动查看更多列。

这个页面有帮助吗?