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§
- Masked
String - A wrapper around a
Stringthat masks its value inDebugandDisplayoutput, preventing accidental exposure in logs.
Functions§
- mask_
between - Mask content between the first occurrence of
start_markerand the followingend_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_lastcharacters. - 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
*.