/// Encrypts the data using the xchacha20-poly1305 algorithm.
Encrypts the data using the xchacha20-poly1305 algorithm.
Encrypts the data using the xchacha20 - poly1305 algorithm .
fn box_seal(key: &Key<Self>, ad: &[u8], data: &[u8]) -> engine::Result<Vec<u8>> {
        let mut cipher = vec![0u8; data.len()];
        let mut tag = vec![0u8; 16];
        let mut nonce: [u8; 24] = [0u8; Self::NONCE_LEN];
        Self::random_buf(&mut nonce)?;
        let key = key.bytes();
        XChaCha20Poly1305::try_encrypt(&key, &nonce, ad, data, &mut cipher, &mut tag)
            .map_err(|_| engine::Error::ProviderError(String::from("Unable to seal data")))?;
        let r#box = [tag.to_vec(), nonce.to_vec(), cipher].concat();
        Ok(r#box)
    }
fn box_seal ( key : & Key < Self > , ad : & [ u8 ] , data : & [ u8 ] ) -> engine :: Result < Vec < u8 > > { let mut cipher = vec ! [ 0u8 data len ( ) ] ; let mut tag = vec ! [ 0u8 16 ] ; let mut nonce : [ u8 ; 24 ] = [ 0u8 ; Self :: NONCE_LEN ] ; Self :: random_buf ( & mut nonce ) ? ; let key = key . bytes ( ) ; XChaCha20Poly1305 :: try_encrypt ( & key , & nonce , ad , data , & mut cipher , & mut tag ) . map_err ( | _ | engine :: Error :: ProviderError ( String :: from ( " " ) ) ) ? ; let r#box = [ tag . to_vec ( ) , nonce . to_vec ( ) , cipher ] . concat ( ) ; Ok ( r#box ) }
Encrypts the data using the xchacha20-poly1305 algorithm.
Encrypts the data using the xchacha20 - poly1305 algorithm .
key
&Key<Self>
ad
&[u8]
data
&[u8]