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. Use CiphertTextVersion::Latest if 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();