Class EncryptionTransformer
加密值转换器
public class EncryptionTransformer : IValueTransformer
- Inheritance
-
EncryptionTransformer
- Implements
- Inherited Members
Remarks
性能优化:
- 使用 Lazy 延迟编译正则表达式
- 使用 RegexOptions.Compiled 提升匹配性能
- 使用 StringComparison.Ordinal 进行前缀检查
- 简单模式使用 string.Contains 快速路径
- 缓存敏感键匹配结果
Constructors
EncryptionTransformer(ICryptoProvider, EncryptionOptions?)
初始化加密值转换器
public EncryptionTransformer(ICryptoProvider provider, EncryptionOptions? options = null)
Parameters
providerICryptoProvider加密提供者
optionsEncryptionOptions加密选项,为 null 时使用默认选项
Properties
Name
转换器名称
public string Name { get; }
Property Value
Priority
优先级,数值越大优先级越高
public int Priority { get; }
Property Value
Methods
ClearCache()
清除敏感键匹配缓存
public void ClearCache()
ShouldTransform(string, string?)
判断是否应该处理该键
public bool ShouldTransform(string key, string? value)
Parameters
Returns
- bool
如果应该处理返回 true,否则返回 false
TransformOnRead(string, string?)
读取时转换(解密)
public string? TransformOnRead(string key, string? value)
Parameters
Returns
- string
解密后的值
TransformOnWrite(string, string?)
写入时转换(加密)
public string? TransformOnWrite(string key, string? value)
Parameters
Returns
- string
加密后的值