Skip to main content

crypto_box_easy

Function crypto_box_easy 

Source
pub fn crypto_box_easy(
    ciphertext: &mut [u8],
    message: &[u8],
    nonce: &Nonce,
    recipient_public_key: &PublicKey,
    sender_secret_key: &SecretKey,
) -> Result<(), Error>
Expand description

Encrypts a message in a box.

Encrypts message with recipient’s public key recipient_public_key, sender’s secret key sender_secret_key, and nonce. The result is placed into ciphertext which must be the length of the message plus CRYPTO_BOX_MACBYTES bytes, for the message tag.

Compatible with libsodium’s crypto_box_easy.

§Errors

Returns an error if message is too long, ciphertext has the wrong length, or recipient_public_key is unacceptable.