Apq.Cfg.Crypto.SensitiveMasker.md 1.7 KB

Apq.Cfg.Crypto

Apq.Cfg.Crypto

SensitiveMasker Class

敏感值脱敏器

public class SensitiveMasker : Apq.Cfg.Security.IValueMasker

Inheritance System.Object 🡒 SensitiveMasker

Implements Apq.Cfg.Security.IValueMasker

Remarks

性能优化: 1. 使用 Lazy 延迟编译正则表达式 2. 使用 RegexOptions.Compiled 提升匹配性能 3. 简单模式使用 string.Contains 快速路径 4. 缓存 ShouldMask 结果 5. 使用 string.Create 减少字符串分配

Constructors
SensitiveMasker(MaskingOptions) 初始化敏感值脱敏器
Methods
ClearCache() 清除 ShouldMask 缓存
IsSimpleContainsPattern(string) 判断是否为简单的 *Keyword* 模式
Mask(string, string) 脱敏处理
ShouldMask(string) 判断是否应该脱敏该键