pub fn encrypt_with_secret_key(
data: &[u8],
key: &SecretKey,
version: CiphertextVersion,
) -> Result<Ciphertext>Expand description
Returns a Ciphertext from cleartext data and a SecretKey.
§Arguments
data- The data to encrypt.key- TheSecretKeyto use. Generate one withgenerate_secret_key.version- Version of the library to encrypt with. UseCiphertextVersion::Latestif you’re not dealing with shared data.
§Returns
Returns a Ciphertext containing the encrypted data.
§Example
use devolutions_crypto::ciphertext::{ encrypt_with_secret_key, CiphertextVersion };
use devolutions_crypto::key::{ generate_secret_key, KeyVersion };
let data = b"somesecretdata";
let key = generate_secret_key(KeyVersion::Latest);
let encrypted_data = encrypt_with_secret_key(data, &key, CiphertextVersion::Latest).unwrap();