Skip to main content

encrypted_stream_with_capacity

Function encrypted_stream_with_capacity 

Source
pub fn encrypted_stream_with_capacity<R: AsyncRead, W: AsyncWrite, A, S>(
    read: R,
    write: W,
    key: &Array<u8, A::KeySize>,
    nonce: &Array<u8, NonceSize<A, S>>,
    buffer_size: usize,
    chunk_size: usize,
) -> EncryptedStream<R, W, 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 async_encrypted_stream::aead_stream::{DecryptorLE31, EncryptorLE31};
use async_encrypted_stream::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).into(), (&nonce).into(), 4096,
512);