pub struct Encryptor { /* private fields */ }Expand description
Initialize the Struct with text as String type using the from() method and perform encryption operations
Implementations§
source§impl Encryptor
impl Encryptor
sourcepub fn encrypt_with(&mut self, key: &String) -> Vec<u8>
pub fn encrypt_with(&mut self, key: &String) -> Vec<u8>
Takes a Key of 32 bytes in length to Encrypt the text initialized with the Encryptor::from() associated function
Examples
use byte_aes::encrypt::Encryptor;
let my_32byte_key = "Thisi$MyKeyT0Encryp!thislastTime".to_owned();
let original_text: String = "I am Omkaram Venkatesh and this is my plain text and some random chars 223@#$^$%*%^(!#@%$~@#$[]]'///\\drewe. Lets see if this gets encrypted now)".to_string();
let original_bytes: &[u8] = original_text.as_bytes();
// You can encrypt your data by providing a slice
let mut encrypt_obj: Encryptor = Encryptor::from(original_text.as_str());
// You can encrypt your data by providing a String
let mut encrypt_obj: Encryptor = Encryptor::from(original_text.as_str());
// You can encrypt your data by providing raw bytes
let mut encrypt_obj: Encryptor = Encryptor::from(original_bytes);
let encrypted_bytes: Vec<u8> = encrypt_obj.encrypt_with(&my_32byte_key);
The output from the variable ‘encrypted_bytes’ would return a Vec<u8>
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Encryptor
impl Send for Encryptor
impl Sync for Encryptor
impl Unpin for Encryptor
impl UnwindSafe for Encryptor
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