Function encrypted_stream_with_capacity

Source
pub fn encrypted_stream_with_capacity<R: AsyncRead, W: AsyncWrite, A, S>(
    read: R,
    write: W,
    key: &GenericArray<u8, A::KeySize>,
    nonce: &GenericArray<u8, NonceSize<A, S>>,
    buffer_size: usize,
    chunk_size: usize,
) -> (ReadHalf<R, Decryptor<A, S>>, WriteHalf<W, Encryptor<A, S>>)
Expand description

Creates a pair of ReadHalf and WriteHalf with default buffer size of buffer_size and chunk size of chunk_size

use chacha20poly1305::aead::stream::{DecryptorLE31, EncryptorLE31};
use chacha20poly1305::XChaCha20Poly1305;

use async_encrypted_stream::{ReadHalf, WriteHalf, encrypted_stream_with_capacity};

let key = [0u8; 32];
let nonce = [0u8; 20];

let (rx, tx) = tokio::io::duplex(4096);
let (mut reader, mut writer): (
    ReadHalf<_, DecryptorLE31<XChaCha20Poly1305>>,
    WriteHalf<_, EncryptorLE31<XChaCha20Poly1305>>,
) = encrypted_stream_with_capacity(rx, tx, key.as_ref().into(), nonce.as_ref().into(), 4096,
512);