7 releases (4 breaking)
Uses new Rust 2024
| 0.5.1 | Sep 20, 2025 |
|---|---|
| 0.5.0 | Sep 12, 2025 |
| 0.4.0 | Jun 28, 2025 |
| 0.3.0 | Dec 2, 2024 |
| 0.1.1 | Jun 7, 2024 |
#1382 in Cryptography
199 downloads per month
Used in 2 crates
23KB
359 lines
Simple encrypted ChaCha20Poly1305 wrapper around an async IO stream.
This library is used by gday_file_transfer, which is used by gday.
In general, I recommend using the well-established rustls for encryption. gday_file_transfer chose this library because Rustls didn't support peer-to-peer connections with a pre-shared key.
Example
#
// Example pipe (like a TCP connection).
let (mut sender, mut receiver) = tokio::io::duplex(64);
// Both peers must have the same key
let key: [u8; 32] = [123; 32];
let handle = tokio::spawn(async move {
// Peer 1 sends "Hello!"
let mut stream = EncryptedStream::encrypt_connection(&mut sender, &key).await?;
stream.write_all(b"Hello!").await?;
stream.flush().await?;
Ok::<(), std::io::Error>(())
});
// Peer 2 receives the "Hello!".
let mut stream = EncryptedStream::encrypt_connection(&mut receiver, &key).await?;
let mut received = [0u8; 6];
stream.read_exact(&mut received).await?;
assert_eq!(b"Hello!", &received);
handle.await??;
gday_encryption
Simple encrypted ChaCha20Poly1305 wrapper around an async IO stream. Uses a streaming chacha20poly1305 cipher.
See the documentation.
Used by
Dependencies
~4–14MB
~134K SLoC