ปิดบัง PII สำหรับ log และ pipeline ด้วย Rust
ปิดบังอีเมลและเบอร์โทรสากลได้อย่างปลอดภัย เร็ว และใช้ dependency น้อย ออกแบบมาสำหรับงาน log และการประมวลผลข้อมูล
alternate_email
ปิดบังอีเมล
คงโดเมนและตัวอักษรแรกของ local part: alice@example.com -> a****@example.com.
public
รูปแบบโทรศัพท์สากล
คงรูปแบบเดิมและ 4 หลักสุดท้าย: +1 (800) 123-4567 -> +1 (***) ***-4567.
construction
ปรับแต่งได้และเบา
เปลี่ยนอักขระปิดบังและคง dependency ให้น้อยที่สุด (ใช้แค่ regex)
การติดตั้งและการใช้งานเบื้องต้น
ใช้ cargo add mask-pii (หรือเพิ่ม mask-pii = "0.1.0" ใน Cargo.toml) แล้วเปิดการปิดบังด้วย builder pattern
การติดตั้ง
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