fn xchachapoly_seal(data: &mut [u8], tag: &mut [u8], ad: &[u8], key: &[u8], nonce: &[u8]) {
    // xor and encrypt the data.
    XChaCha20::xor(key, nonce, 1, data);

    // build a footer
    let mut foot = Vec::with_capacity(16);
    foot.extend_from_slice(&(ad.len() as u64).to_le_bytes());
    foot.extend_from_slice(&(data.len() as u64).to_le_bytes());

    // compute Poly1305 key and auth tag
    let mut pkey = vec![0; 32];
    XChaCha20::xor(key, nonce, 0, &mut pkey);
    Poly1305::chachapoly_auth(tag, ad, data, &foot, &pkey);
}
/// encrypts data in-place and authenticates it
encrypts data in-place and authenticates it
encrypts data in - place and authenticates it
fn xchachapoly_seal(data: &mut [u8], tag: &mut [u8], ad: &[u8], key: &[u8], nonce: &[u8]) {
    // xor and encrypt the data.
    XChaCha20::xor(key, nonce, 1, data);
    // build a footer
    let mut foot = Vec::with_capacity(16);
    foot.extend_from_slice(&(ad.len() as u64).to_le_bytes());
    foot.extend_from_slice(&(data.len() as u64).to_le_bytes());
    // compute Poly1305 key and auth tag
    let mut pkey = vec![0; 32];
    XChaCha20::xor(key, nonce, 0, &mut pkey);
    Poly1305::chachapoly_auth(tag, ad, data, &foot, &pkey);
}
fn xchachapoly_seal ( data : & mut [ u8 ] , tag : & mut [ u8 ] , ad : & [ u8 ] , key : & [ u8 ] , nonce : & [ u8 ] ) { // xor and encrypt the data. XChaCha20 :: xor ( key , nonce , 1 , data ) ; // build a footer let mut foot = Vec :: with_capacity ( 16 ) ; foot . extend_from_slice ( & ( ad . len ( ) as u64 ) . to_le_bytes ( ) ) ; foot . extend_from_slice ( & ( data . len ( ) as u64 ) . to_le_bytes ( ) ) ; // compute Poly1305 key and auth tag let mut pkey = vec ! [ 0 32 ] ; XChaCha20 :: xor ( key , nonce , 0 , & mut pkey ) ; Poly1305 :: chachapoly_auth ( tag , ad , data , & foot , & pkey ) ; }
encrypts data in-place and authenticates it
encrypts data in - place and authenticates it
data
&mut [u8]
tag
&mut [u8]
ad
&[u8]
key
&[u8]
nonce
&[u8]