mask-pii for Rust

Use mask-pii in Rust to mask email addresses and phone numbers with the rules you choose. Run it before logging, audits, or sharing data.

Mask email addresses

Mask part of the address before the @ and keep the domain readable.

Mask phone numbers

Mask the middle digits while keeping the phone number's format and ending where possible. That leaves details you can use to troubleshoot.

Turn on the rules you need

Masking starts off. Turn on the rules you need and pick a masking character that fits your policy.

Install, use, and review the rollout checklist

Install the release we've checked from crates.io and load the Rust API. Run the example to turn on email and phone masking and see the result.

Installation

cargo add mask-pii@0.2.0

Try an example

src/main.rs
use mask_pii::Masker;

fn main() {
    // Configure the masker
    let masker = Masker::new()
        .mask_emails()
        .mask_phones()
        .with_mask_char('#'); // Optional: Use '#' instead of '*'

    let input = "Contact: alice@example.com or 090-1234-5678.";
    
    // Process the text
    let output = masker.process(input);

    println!("{}", output);
    // Output: "Contact: a####@example.com or ###-####-5678."
}
What to check before rollout

Before you use it in production, see the README for edge cases, testing tips, and notes on using it with Rust.