pub struct Crypto { /* private fields */ }Implementations§
Source§impl Crypto
impl Crypto
pub fn new(key_bytes: &[u8; 32]) -> Self
pub fn encrypt(&self, plaintext: &[u8], nonce: &[u8; 24]) -> Result<Vec<u8>>
pub fn decrypt(&self, ciphertext: &[u8], nonce: &[u8; 24]) -> Result<Vec<u8>>
Sourcepub fn generate_nonce() -> [u8; 24]
pub fn generate_nonce() -> [u8; 24]
Generates a secure random 24-byte nonce Note: Returned nonce should be zeroized after use if it contains sensitive material
Sourcepub fn generate_key() -> [u8; 32]
pub fn generate_key() -> [u8; 32]
Generate a random 32-byte key material Caller is responsible for zeroizing the returned bytes
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Crypto
impl RefUnwindSafe for Crypto
impl Send for Crypto
impl Sync for Crypto
impl Unpin for Crypto
impl UnsafeUnpin for Crypto
impl UnwindSafe for Crypto
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more