alternate_email
邮箱脱敏
保留域名与首个本地字符:alice@example.com -> a****@example.com.
public
全球电话格式
保留格式与末 4 位:+1 (800) 123-4567 -> +1 (***) ***-4567.
construction
可定制且轻量
可更换掩码字符,依赖极少(仅 regex)。
安装与基础使用
使用 cargo add mask-pii(或在 Cargo.toml 中添加 mask-pii = "0.1.0"),并通过 builder 启用脱敏。
安装
cargo add mask-pii
使用
main.rs
use mask_pii::Masker;
fn main() {
// Configure the masker
let masker = Masker::new()
.mask_emails()
.mask_phones()
.with_mask_char('#');
let input = "Contact: alice@example.com or 090-1234-5678.";
let output = masker.process(input);
println!("{}", output);
// Output: "Contact: a####@example.com or 090-####-5678."
}
info
重要提示
默认情况下, Masker::new() 不会执行脱敏。请在处理文本前明确启用邮箱/电话过滤器。
上一页
chevron_left 概览下一页
配置 chevron_right