Function devolutions_crypto::ciphertext::encrypt
source · pub fn encrypt(
data: &[u8],
key: &[u8],
version: CiphertextVersion
) -> Result<Ciphertext, Error>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.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.
Example
use devolutions_crypto::ciphertext::{ encrypt, CiphertextVersion };
let data = b"somesecretdata";
let key = b"somesecretkey";
let encrypted_data = encrypt(data, key, CiphertextVersion::Latest).unwrap();