fn extract_nonce(ciphertext: &[u8]) -> (Vec<u8>, Vec<u8>) {
    // Pop off nonce from ciphertext for decryption
    let mut cipher_vec = ciphertext.to_vec();
    let mut nonce_vec: Vec<u8> = Vec::with_capacity(24);
    // Pop off the last 24 bytes of ciphertext
    for _ in 0..24 {
        let nonce_byte = cipher_vec.pop().unwrap_or_default();
        nonce_vec.push(nonce_byte);
    }
    // Reverse nonce since pop works backwards
    let nonce_vec: Vec<u8> = nonce_vec.into_iter().rev().collect();
    // Ship it
    (nonce_vec, cipher_vec)
}
// Extracts the nonce from the end of the ciphertext
Extracts the nonce from the end of the ciphertext
Extracts the nonce from the end of the ciphertext
fn extract_nonce(ciphertext: &[u8]) -> (Vec<u8>, Vec<u8>) {
    // Pop off nonce from ciphertext for decryption
    let mut cipher_vec = ciphertext.to_vec();
    let mut nonce_vec: Vec<u8> = Vec::with_capacity(24);
    // Pop off the last 24 bytes of ciphertext
    for _ in 0..24 {
        let nonce_byte = cipher_vec.pop().unwrap_or_default();
        nonce_vec.push(nonce_byte);
    }
    // Reverse nonce since pop works backwards
    let nonce_vec: Vec<u8> = nonce_vec.into_iter().rev().collect();
    // Ship it
    (nonce_vec, cipher_vec)
}
fn extract_nonce ( ciphertext : & [ u8 ] ) -> ( Vec < u8 > , Vec < u8 > ) { // Pop off nonce from ciphertext for decryption let mut cipher_vec = ciphertext . to_vec ( ) ; let mut nonce_vec : Vec < u8 > = Vec :: with_capacity ( 24 ) ; // Pop off the last 24 bytes of ciphertext for _ in 0 .. 24 { let nonce_byte = cipher_vec . pop ( ) . unwrap_or_default ( ) ; nonce_vec . push ( nonce_byte ) ; } // Reverse nonce since pop works backwards let nonce_vec : Vec < u8 > = nonce_vec . into_iter ( ) . rev ( ) . collect ( ) ; // Ship it ( nonce_vec , cipher_vec ) }
Extracts the nonce from the end of the ciphertext
Extracts the nonce from the end of the ciphertext
ciphertext
&[u8]
ciphertext
&[u8]