Skip to main content

wasmium_securemem/
vault.rs

1use secrecy::Secret;
2
3pub struct EncryptedVault {
4    pub(crate) secret: Secret<Vec<u8>>,
5    pub(crate) nonce: Secret<[u8; 24]>,
6}
7
8#[cfg(feature = "dangerous_debug")]
9use secrecy::ExposeSecret;
10#[cfg(feature = "dangerous_debug")]
11impl EncryptedVault {
12    /// Useful only for testing, don't use in production.
13    pub fn dangerous_debug_hashed(&self) {
14        println!(
15            "EncryptedVault {{
16            secret: {:?},
17            nonce: {:?},
18        }}",
19            blake3::hash(self.secret.expose_secret()).to_hex(),
20            blake3::hash(self.nonce.expose_secret()).to_hex(),
21        );
22    }
23
24    /// Useful only for testing, don't use in production.
25    pub fn dangerous_debug(&self) {
26        println!(
27            "EncryptedVault {{
28            secret: {:?},
29            nonce: {:?},
30        }}",
31            self.secret.expose_secret(),
32            self.nonce.expose_secret(),
33        );
34    }
35}