Async Encrypted Stream
Async Read and Write wrappers around the chacha20 encryption primitives.
This crate exposes a pair of [ReadHalf] and [WriteHalf] structs that works with any [tokio::io::AsyncRead] and [tokio::io::AsyncWrite] respectively.
To use this crate, it is necessary to add chacha20poly1305 as a dependency as well.
= "0.1"
= { = "0.10", = ["stream", "std"] }
Once the necessary dependencies are added, creating the stream is fairly trivial
use ;
use XChaCha20Poly1305;
use ;
// The key and nonce used must be the same on both ends of the stream
// NOTE: the size of the key and nonce values are defined by the type of Encryption used
let key = ;
let nonce = ;
let = duplex;
let : = encrypted_stream;