pub fn wipe_memory(data: &mut [u8])Expand description
Overwrites a byte buffer with zeros in a way that cannot be optimized away.
Uses the Zeroize trait from the zeroize crate to guarantee that the
memory is cleared even in release builds. This is essential for securely
erasing sensitive material such as secret keys from memory.
§Parameters
data– A mutable byte slice whose contents will be zeroized.
§Examples
use age_setup::security::wipe_memory;
let mut secret = vec![1, 2, 3, 4];
wipe_memory(&mut secret);
assert_eq!(secret, vec![0, 0, 0, 0]);Empty buffers are handled gracefully:
use age_setup::security::wipe_memory;
let mut empty: Vec<u8> = vec![];
wipe_memory(&mut empty);
assert_eq!(empty, vec![]);