邮箱脱敏
Preserves the domain and the first local character: alice@example.com -> a****@example.com.
全球电话格式
Keeps formatting and the last 4 digits: +1 (800) 123-4567 -> +1 (***) ***-4567.
可定制且轻量
Change the mask character and keep dependencies minimal (regex only).
安装与基础使用
请使用 cargo add mask-pii(或在 Cargo.toml 中添加 mask-pii = "0.2.0"),并通过构建器启用脱敏。
安装
使用
use mask_pii::Masker;
fn main() {
// 配置脱敏器
let masker = Masker::new()
.mask_emails()
.mask_phones()
.with_mask_char('#');
let input = "联系: alice@example.com or 090-1234-5678.";
let output = masker.process(input);
println!("{}", output);
// 输出: "联系: a####@example.com or 090-####-5678."
}
重要提示
默认情况下, Masker::new() 不会执行脱敏。请在处理文本前显式启用邮箱/电话过滤器。