1 unstable release
0.1.2 | Oct 14, 2022 |
---|---|
0.1.1 |
|
0.1.0 |
|
#1018 in Asynchronous
38KB
528 lines
async_io_crypto
A rust library for handling AsyncRead with ciphering / deciphering. It combines aead crate with tokio IO traits
lib.rs
:
Provides a wrapper around a AsyncRead
#[tokio::main]
let key = b"my very super super secret key!!";
let plaintext = b"hello world!";
let mut csprng = rand_chacha::ChaCha20Rng::from_entropy();
let cipher: ChaCha20Poly1305 = ChaCha20Poly1305::new(Key::from_slice(key));
let (mut ci_reader, nonce) = CipherRead::new(&plaintext[..], cipher.clone(), &mut csprng);
let mut ciphered = Vec::new();
ci_reader.read_to_end(&mut ciphered).await.unwrap();
let mut deci_reader = DecipherRead::new(&ciphered[..], cipher, nonce.as_slice());
let mut deciphered = Vec::new();
deci_reader.read_to_end(&mut deciphered).await.unwrap();
assert_eq!(deciphered, plaintext);
Dependencies
~3.5–5MB
~81K SLoC