Expand description
A wrapper type for secret values that prevents accidental leakage.
Secret<T> provides the following guarantees:
- Debug and Display always show
[REDACTED]instead of the actual value - The inner value is zeroized on drop
- Access to the inner value requires an explicit
expose()call - Comparisons use constant-time operations to prevent timing attacks
§Type Constraints
Important: Secret<T> is designed for flat data types without pointers
(e.g. [u8; N]). It does NOT provide full protection for types with
indirection. Types like Vec<T>, String, or Box<T> will only have their
metadata (pointer, length, capacity) zeroized, the referenced data remains
intact. Do not use Secret with types that contain pointers.
Structs§
- Secret
- A wrapper for secret values that prevents accidental leakage.