pub struct StreamCipher { /* private fields */ }Expand description
Stream cipher for large file encryption.
Each chunk is independently authenticated, allowing:
- Constant memory usage regardless of file size
- Early detection of tampering
- Potential for parallel processing
Implementations§
Source§impl StreamCipher
impl StreamCipher
Sourcepub fn with_chunk_size(key: [u8; 32], chunk_size: usize) -> Self
pub fn with_chunk_size(key: [u8; 32], chunk_size: usize) -> Self
Create with custom chunk size.
Sourcepub fn chunk_size(&self) -> usize
pub fn chunk_size(&self) -> usize
Get the chunk size.
Sourcepub fn encrypt_stream<'a>(
&'a self,
data: &'a [u8],
) -> Result<StreamEncryptor<'a>>
pub fn encrypt_stream<'a>( &'a self, data: &'a [u8], ) -> Result<StreamEncryptor<'a>>
Encrypt a stream of data.
Returns an iterator over encrypted chunks. First chunk is the header containing stream salt.
Sourcepub fn decrypt_stream(&self, encrypted: &[u8]) -> Result<Vec<u8>>
pub fn decrypt_stream(&self, encrypted: &[u8]) -> Result<Vec<u8>>
Decrypt a stream of encrypted chunks.
Trait Implementations§
Source§impl Drop for StreamCipher
impl Drop for StreamCipher
Auto Trait Implementations§
impl Freeze for StreamCipher
impl RefUnwindSafe for StreamCipher
impl Send for StreamCipher
impl Sync for StreamCipher
impl Unpin for StreamCipher
impl UnsafeUnpin for StreamCipher
impl UnwindSafe for StreamCipher
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