pub fn encrypt_with_password(
data: &[u8],
password: &[u8],
derivation_parameters: DerivationParameters,
ciphertext_version: CiphertextVersion,
) -> Result<KdfEncryptedData>Expand description
Encrypts data with a key derived from password and returns a self-contained blob.
Equivalent to calling encrypt_with_password_and_aad with an empty AAD.
§Arguments
data- The plaintext data to encrypt.password- The password from which the encryption key is derived.derivation_parameters- Pre-built key derivation parameters.ciphertext_version- Cipher to use.CiphertextVersion::Latestis recommended.
§Returns
Returns a KdfEncryptedData blob containing the key derivation parameters and the ciphertext.
§Example
use devolutions_crypto::derive_encrypt::encrypt_with_password;
use devolutions_crypto::key_derivation::Argon2;
use devolutions_crypto::CiphertextVersion;
let params = Argon2::new().parameters();
let blob = encrypt_with_password(b"secret", b"password", params, CiphertextVersion::Latest).unwrap();
let plaintext = blob.decrypt_with_password(b"password").unwrap();
assert_eq!(plaintext, b"secret");