pub struct SecretObfuscator { /* private fields */ }Expand description
Bidirectional secret obfuscator.
Construct with a list of SecretEntry values, then call
obfuscate on text before it reaches the LLM and
deobfuscate on text coming back.
Implementations§
Source§impl SecretObfuscator
impl SecretObfuscator
Sourcepub fn new(entries: &[SecretEntry]) -> Self
pub fn new(entries: &[SecretEntry]) -> Self
Construct from a list of secret entries.
Secrets shorter than 8 chars in obfuscate mode are silently skipped (false-positive avoidance). Invalid regex entries (future extension) are also skipped.
Sourcepub fn has_secrets(&self) -> bool
pub fn has_secrets(&self) -> bool
Returns true if any secrets were configured.
Sourcepub fn obfuscate(&self, text: &str) -> String
pub fn obfuscate(&self, text: &str) -> String
Obfuscate all known secrets in text.
Obfuscate-mode secrets are replaced with #XXXX# placeholders
(reversible via deobfuscate). Replace-mode
secrets are replaced with deterministic strings (NOT reversible).
Processing order: replace-mode first (longest first to handle prefix overlaps), then obfuscate-mode (longest first).
Sourcepub fn deobfuscate(&self, text: &str) -> String
pub fn deobfuscate(&self, text: &str) -> String
Deobfuscate #XXXX# placeholders back to their original secrets.
Only obfuscate-mode placeholders are reversed. Replace-mode replacements are permanent (by design — the original is never recoverable).