secret
Keeping secrets out of logs: a wrapper that never prints its value, redaction, masking and credential detection.
Secret hides a value from Debug and Display; redact and mask clean text you already have;
detect and scan recognize well-known token formats (GitHub, AWS, Slack, Stripe, Google, npm, JWT,
PEM keys). None of it wipes memory (that needs unsafe code, which this crate forbids).
Install
Section titled “Install”Cargo feature secret (enabled by default). To compile only this module:
or in Cargo.toml:
Import path: helpers4::secret.
| Item | What it does |
|---|---|
detect | Recognizes a well-known credential format: the whole of token must look like one. |
mask | Hides a secret but for its last few characters, such as "****************7890". |
REDACTED | The text shown in place of a redacted secret. |
redact | Replaces every occurrence of each of secrets in text with [REDACTED]. |
Finding | One credential found by scan. |
scan | Finds the well-known credentials in text. |
Secret | A value that must not leak through logs, error messages or {:?}: printing it shows [REDACTED] instead of the content. |
TokenKind | A well-known kind of credential, as recognized by detect. |
