INNER CODE UNIT · Rust
encrypt
matrix-org/vodozemac · src/cipher/mod.rs:173
pub fn encrypt(&self, plaintext: &[u8]) -> Vec<u8> {
let cipher = Aes256CbcEnc::new(self.keys.aes_key(), self.keys.iv());
cipher.encrypt_padded_vec::<Pkcs7>(plaintext)
}
/// Generates a message authentication code (MAC) for the given ciphertext.
///
/// **Warning**: This is a low-level function and must be called after the
/// [`Cipher::encrypt`] method. The ciphertext produced by
/// [`Cipher::encrypt`] must be passed as the argument to this method.
#[allow(unreachable_pub)]
pub fn mac(&self, message: &[u8]) -> Mac {
let mut hmac = self.get_hmac();
hmac.update(message);
let mac_bytes = hmac.finalize().into_bytes();
let mut mac = [0u8; 32];