Function encrypt_with_params

Source
pub fn encrypt_with_params(
    plaintext: impl AsRef<[u8]>,
    passphrase: impl AsRef<[u8]>,
    params: Params,
) -> Result<Vec<u8>>
Available on crate feature alloc only.
Expand description

Encrypts plaintext with the specified Params and into a newly allocated Vec.

This uses the Argon2 type created by Algorithm::default and the Argon2 version created by Version::default.

This is a convenience function for using Encryptor::with_params and Encryptor::encrypt_to_vec.

§Errors

Returns Err if the Argon2 context is invalid.

§Examples

let data = b"Hello, world!\n";
let passphrase = "passphrase";

let params = Params::new(32, 3, 4, None).unwrap();
let ciphertext = abcrypt::encrypt_with_params(data, passphrase, params).unwrap();