Skip to main content

MagicCryptTrait

Trait MagicCryptTrait 

Source
pub trait MagicCryptTrait {
Show 17 methods // Required methods fn new<S: AsRef<[u8]>, V: AsRef<[u8]>>(key: S, iv: Option<V>) -> Self; fn encrypt_to_bytes<T: ?Sized + AsRef<[u8]>>(&self, data: &T) -> Vec<u8> ⓘ; fn encrypt_reader_to_bytes( &self, reader: &mut dyn Read, ) -> Result<Vec<u8>, MagicCryptError>; fn encrypt_reader_to_writer2<N: ArraySize + PartialDiv<U16> + IsGreaterOrEqual<U16, Output = True>>( &self, reader: &mut dyn Read, writer: &mut dyn Write, ) -> Result<(), MagicCryptError>; fn decrypt_bytes_to_bytes<T: ?Sized + AsRef<[u8]>>( &self, bytes: &T, ) -> Result<Vec<u8>, MagicCryptError>; fn decrypt_reader_to_bytes( &self, reader: &mut dyn Read, ) -> Result<Vec<u8>, MagicCryptError>; fn decrypt_reader_to_writer2<N: ArraySize + PartialDiv<U16> + IsGreaterOrEqual<U16, Output = True>>( &self, reader: &mut dyn Read, writer: &mut dyn Write, ) -> Result<(), MagicCryptError>; // Provided methods fn encrypt_str_to_base64<S: AsRef<str>>(&self, string: S) -> String { ... } fn encrypt_str_to_bytes<S: AsRef<str>>(&self, string: S) -> Vec<u8> ⓘ { ... } fn encrypt_bytes_to_base64<T: ?Sized + AsRef<[u8]>>( &self, bytes: &T, ) -> String { ... } fn encrypt_bytes_to_bytes<T: ?Sized + AsRef<[u8]>>( &self, bytes: &T, ) -> Vec<u8> ⓘ { ... } fn encrypt_to_base64<T: ?Sized + AsRef<[u8]>>(&self, data: &T) -> String { ... } fn encrypt_reader_to_base64( &self, reader: &mut dyn Read, ) -> Result<String, MagicCryptError> { ... } fn encrypt_reader_to_writer( &self, reader: &mut dyn Read, writer: &mut dyn Write, ) -> Result<(), MagicCryptError> { ... } fn decrypt_base64_to_string<S: AsRef<str>>( &self, base64: S, ) -> Result<String, MagicCryptError> { ... } fn decrypt_base64_to_bytes<S: AsRef<str>>( &self, base64: S, ) -> Result<Vec<u8>, MagicCryptError> { ... } fn decrypt_reader_to_writer( &self, reader: &mut dyn Read, writer: &mut dyn Write, ) -> Result<(), MagicCryptError> { ... }
}
Expand description

Methods for MagicCrypt and MagicCrypt<bits> structs.

Required Methods§

Source

fn new<S: AsRef<[u8]>, V: AsRef<[u8]>>(key: S, iv: Option<V>) -> Self

Source

fn encrypt_to_bytes<T: ?Sized + AsRef<[u8]>>(&self, data: &T) -> Vec<u8> ⓘ

Source

fn encrypt_reader_to_bytes( &self, reader: &mut dyn Read, ) -> Result<Vec<u8>, MagicCryptError>

Read all input into memory and return its encrypted bytes.

Source

fn encrypt_reader_to_writer2<N: ArraySize + PartialDiv<U16> + IsGreaterOrEqual<U16, Output = True>>( &self, reader: &mut dyn Read, writer: &mut dyn Write, ) -> Result<(), MagicCryptError>

Encrypt data in chunks with a buffer of N bytes and flush the writer on success.

N must be at least 16 and a multiple of 16. If an error occurs, the writer may already contain part of the encrypted data.

Source

fn decrypt_bytes_to_bytes<T: ?Sized + AsRef<[u8]>>( &self, bytes: &T, ) -> Result<Vec<u8>, MagicCryptError>

Source

fn decrypt_reader_to_bytes( &self, reader: &mut dyn Read, ) -> Result<Vec<u8>, MagicCryptError>

Read all input into memory and return its decrypted bytes.

Source

fn decrypt_reader_to_writer2<N: ArraySize + PartialDiv<U16> + IsGreaterOrEqual<U16, Output = True>>( &self, reader: &mut dyn Read, writer: &mut dyn Write, ) -> Result<(), MagicCryptError>

Decrypt data in chunks with a buffer of N bytes and flush the writer on success.

N must be at least 16 and a multiple of 16. If an error occurs, the writer may already contain part of the decrypted data.

Provided Methods§

Source

fn encrypt_str_to_base64<S: AsRef<str>>(&self, string: S) -> String

Source

fn encrypt_str_to_bytes<S: AsRef<str>>(&self, string: S) -> Vec<u8> ⓘ

Source

fn encrypt_bytes_to_base64<T: ?Sized + AsRef<[u8]>>(&self, bytes: &T) -> String

Source

fn encrypt_bytes_to_bytes<T: ?Sized + AsRef<[u8]>>(&self, bytes: &T) -> Vec<u8> ⓘ

Source

fn encrypt_to_base64<T: ?Sized + AsRef<[u8]>>(&self, data: &T) -> String

Source

fn encrypt_reader_to_base64( &self, reader: &mut dyn Read, ) -> Result<String, MagicCryptError>

Read all input into memory and return its encrypted data as Base64.

Source

fn encrypt_reader_to_writer( &self, reader: &mut dyn Read, writer: &mut dyn Write, ) -> Result<(), MagicCryptError>

Encrypt data in chunks with a 4096-byte buffer and flush the writer on success.

If an error occurs, the writer may already contain part of the encrypted data.

Source

fn decrypt_base64_to_string<S: AsRef<str>>( &self, base64: S, ) -> Result<String, MagicCryptError>

Source

fn decrypt_base64_to_bytes<S: AsRef<str>>( &self, base64: S, ) -> Result<Vec<u8>, MagicCryptError>

Source

fn decrypt_reader_to_writer( &self, reader: &mut dyn Read, writer: &mut dyn Write, ) -> Result<(), MagicCryptError>

Decrypt data in chunks with a 4096-byte buffer and flush the writer on success.

If an error occurs, the writer may already contain part of the decrypted data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§