Table of Contents

Class CfgBuilderExtensions

Namespace
Apq.Cfg.Crypto.DataProtection
Assembly
Apq.Cfg.Crypto.DataProtection.dll

CfgBuilder 的 Data Protection 加密扩展方法

public static class CfgBuilderExtensions
Inheritance
CfgBuilderExtensions
Inherited Members

Methods

AddDataProtectionEncryption(CfgBuilder, IDataProtectionProvider, string, Action<EncryptionOptions>?)

添加 Data Protection 加密支持

public static CfgBuilder AddDataProtectionEncryption(this CfgBuilder builder, IDataProtectionProvider provider, string purpose = "Apq.Cfg", Action<EncryptionOptions>? configure = null)

Parameters

builder CfgBuilder

配置构建器

provider IDataProtectionProvider

Data Protection 提供者

purpose string

保护目的,用于隔离不同用途的加密数据

configure Action<EncryptionOptions>

加密选项配置委托

Returns

CfgBuilder

配置构建器实例,支持链式调用

Examples

var dataProtectionProvider = DataProtectionProvider.Create("MyApp");
var cfg = new CfgBuilder()
    .AddJsonFile("config.json", level: 0)
    .AddDataProtectionEncryption(dataProtectionProvider)
    .Build();

AddDataProtectionEncryption(CfgBuilder, DirectoryInfo, string, string, Action<EncryptionOptions>?)

添加 Data Protection 加密支持(使用指定目录存储密钥)

public static CfgBuilder AddDataProtectionEncryption(this CfgBuilder builder, DirectoryInfo keyDirectory, string applicationName, string purpose = "Apq.Cfg", Action<EncryptionOptions>? configure = null)

Parameters

builder CfgBuilder

配置构建器

keyDirectory DirectoryInfo

密钥存储目录

applicationName string

应用程序名称

purpose string

保护目的

configure Action<EncryptionOptions>

加密选项配置委托

Returns

CfgBuilder

配置构建器实例,支持链式调用

Examples

var cfg = new CfgBuilder()
    .AddJsonFile("config.json", level: 0)
    .AddDataProtectionEncryption(new DirectoryInfo("/keys"), "MyApp")
    .Build();

AddDataProtectionEncryption(CfgBuilder, string, string, Action<EncryptionOptions>?)

添加 Data Protection 加密支持(使用默认提供者)

public static CfgBuilder AddDataProtectionEncryption(this CfgBuilder builder, string applicationName, string purpose = "Apq.Cfg", Action<EncryptionOptions>? configure = null)

Parameters

builder CfgBuilder

配置构建器

applicationName string

应用程序名称,用于密钥隔离

purpose string

保护目的

configure Action<EncryptionOptions>

加密选项配置委托

Returns

CfgBuilder

配置构建器实例,支持链式调用

Examples

var cfg = new CfgBuilder()
    .AddJsonFile("config.json", level: 0)
    .AddDataProtectionEncryption("MyApp")
    .Build();