#secure #p2p #tcp #networking

p2ps

Easy to implement security for p2p connections

2 releases

0.1.2 Feb 24, 2025
0.1.1 Feb 21, 2025
0.1.0 Feb 19, 2025

#2174 in Network programming

Download history 364/week @ 2025-02-19 42/week @ 2025-02-26

406 downloads per month

MIT license

14KB
171 lines

p2ps

p2ps is a Rust library designed to make it easy to establish a secure connection between two peers using the Diffie-Hellman algorithm.

Usage example (Sync)

Peer A

use std::net::TcpListener;
use p2ps::P2psConn;

let listener = TcpListener::bind("peer_a_address:port")?;
let (mut stream, _) = listener.accept()?;
let mut p2ps_conn = P2psConn::listen_handshake(stream)?;

Peer B

use std::net::TcpStream;
use p2p_secure::P2psConn;

let stream = TcpStream::connect("peer_a_address:port")?;
let mut p2ps_conn = P2psConn::send_handshake(&mut stream)?;

now both peers can use their p2ps_conn to share data

Peer A

let data = b"Hello, peer B!";
p2ps_conn.write(data)?;

Peer B

let decrypted_data = p2ps_conn.read()?;
println!("Received data: {}", String::from_utf8_lossy(&decrypted_data));

Loking for Contributors & Ideas

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.

License

This project is licensed under the MIT License – see the LICENSE file for details.

Dependencies

~5–13MB
~137K SLoC