pub fn encrypt_with_aad(
data: &[u8],
key: &[u8],
aad: &[u8],
version: CiphertextVersion,
) -> Result<Ciphertext>Expand description
Returns an Ciphertext from cleartext data and a key.
§Arguments
data- The data to encrypt.key- The key to use. The recommended size is 32 bytes.aad- Additionnal data to authenticate alongside the ciphertext.version- Version of the library to encrypt with. UseCiphertTextVersion::Latestif you’re not dealing with shared data.
§Returns
Returns a Ciphertext containing the encrypted data, which also authenticates the aad argument.
§Example
use devolutions_crypto::ciphertext::{ encrypt_with_aad, CiphertextVersion };
let data = b"somesecretdata";
let key = b"somesecretkey";
let aad = b"somepublicdata";
let encrypted_data = encrypt_with_aad(data, key, aad, CiphertextVersion::Latest).unwrap();