A simple library for keeping secrets out of logs.
Redact provides a wrapper that prevents secrets from appearing in logs.
```rust use redact::Secret;
let encryptionkey = Secret::new("hello world"); asserteq!("[REDACTED &str]", format!("{encryption_key:?}")) ```
The underlying secret contained within the wrapper can only be accessed using the [ExposeSecret] trait.
```rust use redact::{Secret, ExposeSecret};
let encryptionkey = Secret::new("hello world"); asserteq!("hello world", *encryptionkey.exposesecret()) ```
The Secret
type doubles as a useful documentation tool.
Documenting values mantainers should be careful with.
Secrecy was the original inspiration for this crate and it has a very similar API.
One significant differnece is that secrecy requires that all secrets implement [Zeroize
] so that it can cleanly wipe secrets from memory after they are dropped.
This unfortiantly limits the types of values that secrecy can wrap in a Secret
since every type has to be aware of Zeroize
.
Redact relaxes this requirment allowing all types to be Secret
s. If you need zeroization consider secrecy.
Secrets provides even stronger memory protecton than secrecy using [mlock(2)
]/[mprotect(2)
] among other things.
If you need strong memory protection before a Secret
is dropped consider secrets.