| Crates.io | p2ps |
| lib.rs | p2ps |
| version | 0.2.0 |
| created_at | 2025-02-19 03:38:53.666384+00 |
| updated_at | 2025-06-18 22:58:42.235506+00 |
| description | Easy to implement security for p2p connections |
| homepage | |
| repository | https://github.com/Bicheka/p2ps |
| max_upload_size | |
| id | 1560908 |
| size | 38,801 |
p2ps is a Rust library designed to make it easy to establish a secure connection between two peers using the Diffie-Hellman algorithm.
use tokio::net::TcpListener;
use p2ps::Seconn;
let listener = TcpListener::bind("127.0.0.1:7777").await?;
let (stream, _) = listener.accept().await?;
let mut p2ps_conn = Seconn::listen_handshake(stream).await?;
use tokio::net::TcpStream;
use p2ps::Seconn;
let stream = TcpStream::connect("127.0.0.1:7777").await?;
let mut p2ps_conn = Seconn::send_handshake(stream).await?;
now both peers can use their p2ps_conn to share data
let data = b"Hello, peer B!";
p2ps_conn.write(data).await?;
let decrypted_data = p2ps_conn.read().await?;
println!("Received: {}", String::from_utf8_lossy(&decrypted_data));
This project is in active development, and I need help! Contributions are welcome, whether it's improving the implementation, fixing bugs, or adding new features. Feel free to open issues, submit pull requests, and share any new ideas that could improve the project.
This project is licensed under the MIT License – see the LICENSE file for details.