pub fn crypto_secretbox(msg: &[u8], nonce: &[u8], key: &[u8]) -> Vec<u8> {
    let (mut auth, mut stream) = crypto_secretbox_setup(nonce, key);
    let taglen = crypto_secretbox_OVERHEADBYTES;

    // Allocate the backing storage for the tag + ciphertext.
    let outlen = crypto_secretbox_OVERHEADBYTES + msg.len();
    let mut out: Vec<u8> = repeat(0).take(outlen).collect();

    // Encrypt the plaintext.
    stream.process(msg, &mut out.as_mut_slice()[taglen..]);

    // Calculate the tag, and prepend it to the ciphertext.
    auth.input(&(out[taglen..]));
    auth.raw_result(&mut out.as_mut_slice()[..taglen]);

    out
}
/// Secret-key authenticated encryption.
///
/// The crypto_secretbox function encrypts and authenticates a message,
/// using a secret key and nonce, returning the corresponding ciphertext.
/// This function asserts if key.len() is not crypto_secretbox_KEYBYTES,
/// or if nonce.len() is not crypto_secretbox_NONCEBYTES.
///
/// Nonces MUST NOT be reused with a given key.  Nonces are long enough that
/// randomly generated nonces have negligible risk of collision.
///
/// # Arguments
/// * msg - The plaintext to encrypt/authenticate.
/// * nonce - The nonce to use for the encryption/authentication.
/// * key - The key to use for the encryption/authentication.
Secret-key authenticated encryption.
The crypto_secretbox function encrypts and authenticates a message,
using a secret key and nonce, returning the corresponding ciphertext.
This function asserts if key.len() is not crypto_secretbox_KEYBYTES,
or if nonce.len() is not crypto_secretbox_NONCEBYTES.

Nonces MUST NOT be reused with a given key.  Nonces are long enough that
randomly generated nonces have negligible risk of collision.
Secret - key authenticated encryption . The crypto_secretbox function encrypts and authenticates a message using a secret key and nonce returning the corresponding ciphertext . This function asserts if key . len () is not crypto_secretbox_KEYBYTES or if nonce . len () is not crypto_secretbox_NONCEBYTES . Nonces MUST NOT be reused with a given key . Nonces are long enough that randomly generated nonces have negligible risk of collision .
pub fn crypto_secretbox(msg: &[u8], nonce: &[u8], key: &[u8]) -> Vec<u8> {
    let (mut auth, mut stream) = crypto_secretbox_setup(nonce, key);
    let taglen = crypto_secretbox_OVERHEADBYTES;
    // Allocate the backing storage for the tag + ciphertext.
    let outlen = crypto_secretbox_OVERHEADBYTES + msg.len();
    let mut out: Vec<u8> = repeat(0).take(outlen).collect();
    // Encrypt the plaintext.
    stream.process(msg, &mut out.as_mut_slice()[taglen..]);
    // Calculate the tag, and prepend it to the ciphertext.
    auth.input(&(out[taglen..]));
    auth.raw_result(&mut out.as_mut_slice()[..taglen]);
    out
}
pub fn crypto_secretbox ( msg : & [ u8 ] , nonce : & [ u8 ] , key : & [ u8 ] ) -> Vec < u8 > { let ( mut auth , mut stream ) = crypto_secretbox_setup ( nonce , key ) ; let taglen = crypto_secretbox_OVERHEADBYTES ; // Allocate the backing storage for the tag + ciphertext. let outlen = crypto_secretbox_OVERHEADBYTES + msg . len ( ) ; let mut out : Vec < u8 > = repeat ( 0 ) . take ( outlen ) . collect ( ) ; // Encrypt the plaintext. stream . process ( msg , & mut out . as_mut_slice ( ) [ taglen .. ] ) ; // Calculate the tag, and prepend it to the ciphertext. auth . input ( & ( out [ taglen .. ] ) ) ; auth . raw_result ( & mut out . as_mut_slice ( ) [ .. taglen ] ) ; out }
Secret-key authenticated encryption.
Secret - key authenticated encryption .
msg
&[u8]
nonce
&[u8]
key
&[u8]
msg
&[u8]
nonce
&[u8]
key
&[u8]