Skip to main content

Crate philiprehberger_mask

Crate philiprehberger_mask 

Source
Expand description

§philiprehberger-mask

Data masking and redaction for strings, emails, and sensitive data. Zero dependencies — std only.

§Examples

use philiprehberger_mask::{mask_string, mask_email, mask_credit_card, MaskedString};

assert_eq!(mask_string("secret"), "******");
assert_eq!(mask_email("john@example.com"), "j***@example.com");
assert_eq!(mask_credit_card("4111-1111-1111-1111"), "****-****-****-1111");

let masked = MaskedString::new("api-key-123");
println!("{}", masked); // prints "***********"
assert_eq!(masked.reveal(), "api-key-123");

Structs§

MaskedString
A wrapper around a String that masks its value in Debug and Display output, preventing accidental exposure in logs.

Functions§

mask_between
Mask content between the first occurrence of start_marker and the following end_marker.
mask_credit_card
Mask a credit card number, preserving formatting.
mask_digits
Replace all ASCII digits in a string with *.
mask_email
Mask an email address.
mask_iban
Mask an IBAN, keeping the country code (first 2 characters) and last 4 characters.
mask_partial
Mask all but the last show_last characters.
mask_phone
Mask digits in a phone number except the last 4 digits.
mask_ssn
Mask a Social Security Number, keeping only the last 4 digits.
mask_string
Replace all characters in a string with *.