redact
Replaces every occurrence of each of secrets in text with [REDACTED].
Meant for text that is about to be logged or shown (a command line, an HTTP dump, an error message) when you know the secret values. Longer secrets are replaced first, so a secret that contains another one is hidden whole. Empty secrets are ignored. Only exact occurrences are found: a secret that was transformed (encoded, split over lines) is not.
Import
Section titled “Import”Cargo feature secret (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | &str | The text to clean. |
secrets | &[&str] | The values to hide. |
Returns
Section titled “Returns”String — The text with every occurrence replaced.
