Skip to main content

crypto_box_seal

Function crypto_box_seal 

Source
pub fn crypto_box_seal(
    ciphertext: &mut [u8],
    message: &[u8],
    recipient_public_key: &PublicKey,
) -> Result<(), Error>
Expand description

Encrypts and seals a message in a box.

Encrypts message with recipient’s public key recipient_public_key, using an ephemeral keypair and nonce. The length of ciphertext must be the length of the message plus CRYPTO_BOX_SEALBYTES bytes for the message tag and ephemeral public key.

Compatible with libsodium’s crypto_box_seal.

§Errors

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

§Panics

Panics if the operating system’s random number generator fails while creating the ephemeral keypair.