1
0

Apq.Cfg.Crypto.DataProtection.CfgBuilderExtensions.AddDataProtectionEncryption.md 11 KB

Apq.Cfg.Crypto.DataProtection.CfgBuilderExtensions

CfgBuilderExtensions.AddDataProtectionEncryption Method

Overloads
AddDataProtectionEncryption(this CfgBuilder, IDataProtectionProvider, string, Action<EncryptionOptions>) 添加 Data Protection 加密支持
AddDataProtectionEncryption(this CfgBuilder, string, string, Action<EncryptionOptions>) 添加 Data Protection 加密支持(使用默认提供者)
AddDataProtectionEncryption(this CfgBuilder, DirectoryInfo, string, string, Action<EncryptionOptions>) 添加 Data Protection 加密支持(使用指定目录存储密钥)

CfgBuilderExtensions.AddDataProtectionEncryption(this CfgBuilder, IDataProtectionProvider, string, Action<EncryptionOptions>) Method

添加 Data Protection 加密支持

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

Parameters

builder Apq.Cfg.CfgBuilder

配置构建器

provider Microsoft.AspNetCore.DataProtection.IDataProtectionProvider

Data Protection 提供者

purpose System.String

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

configure System.Action<Apq.Cfg.Crypto.EncryptionOptions>

加密选项配置委托

Returns

Apq.Cfg.CfgBuilder
配置构建器实例,支持链式调用

Example

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

CfgBuilderExtensions.AddDataProtectionEncryption(this CfgBuilder, string, string, Action<EncryptionOptions>) Method

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

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

Parameters

builder Apq.Cfg.CfgBuilder

配置构建器

applicationName System.String

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

purpose System.String

保护目的

configure System.Action<Apq.Cfg.Crypto.EncryptionOptions>

加密选项配置委托

Returns

Apq.Cfg.CfgBuilder
配置构建器实例,支持链式调用

Example

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

CfgBuilderExtensions.AddDataProtectionEncryption(this CfgBuilder, DirectoryInfo, string, string, Action<EncryptionOptions>) Method

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

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

Parameters

builder Apq.Cfg.CfgBuilder

配置构建器

keyDirectory System.IO.DirectoryInfo

密钥存储目录

applicationName System.String

应用程序名称

purpose System.String

保护目的

configure System.Action<Apq.Cfg.Crypto.EncryptionOptions>

加密选项配置委托

Returns

Apq.Cfg.CfgBuilder
配置构建器实例,支持链式调用

Example

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