Function webcryptobox::derive_and_encrypt
source · pub fn derive_and_encrypt(
private_key: EcKey<Private>,
public_key: EcKey<Public>,
data: &[u8]
) -> Result<Vec<u8>, ErrorStack>
Expand description
Derives AES key from given private and public key and encrypts message.
§Example:
let alice = webcryptobox::generate_private_key().unwrap();
let bob = webcryptobox::generate_private_key().unwrap();
let bobs_public_key = webcryptobox::get_public_key(&bob).unwrap();
let data = (b"a secret message").to_vec();
let encrypted_message = webcryptobox::derive_and_encrypt(alice, bobs_public_key, &data);