sanitization 1.0.0-rc.2

Dependency-free no_std secret memory sanitization with safe defaults and an explicit volatile wipe backend.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#[cfg(feature = "alloc")]
use sanitization::{SecretString, SecretVec};

fn main() {
    #[cfg(feature = "alloc")]
    {
        let mut token = SecretString::with_capacity(32);
        token.push_str("bearer-token");
        assert_eq!(token.try_with_secret(str::len), Ok(12));

        let mut bytes = SecretVec::with_capacity(16);
        bytes.extend_from_slice(b"secret");
        assert_eq!(bytes.with_secret(|value| value.len()), 6);
    }
}