r/Python • • 24d ago

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

31 Upvotes

170 comments sorted by

View all comments

1

u/tonyd365 7d ago

lanpair: pair two machines on your LAN once with a QR code; after that every message is encrypted, signed and replay-proof.

What My Project Does

A host (a front desk PC, a hub) shows a QR code, a device (a room PC, a Raspberry Pi) scans it once, and from then on they exchange messages that are encrypted to the recipient (X25519 + ChaCha20-Poly1305), signed (Ed25519) and checked for replays, also across restarts. It handles mDNS discovery, keys in the OS keychain, UDP/TCP transport, and forward secrecy with short-lived session keys.

from lanpair import Host

with Host("Front desk") as host:
    if not host.devices:
        host.pairing_offer().print_qr()
        host.wait_for_pairing(timeout=300)
    for msg in host.messages():   # already verified
        print(msg.sender.name, msg.body)

Target Audience

Home-lab / Raspberry Pi projects, small venues, local tools: anything where machines on one network send each other commands and an open HTTP endpoint is too trusting. Stable 1.x API; no external security review yet.

Comparison

Plain HTTP/UDP: anyone on the Wi-Fi can send or replay commands. Self-managed TLS: secure, but you run a CA and build pairing and replay protection yourself. Noise/libsodium: the right primitives, but pairing, key storage and discovery are still yours to build.

Tested on Linux/macOS/Windows with Python 3.10–3.15, fuzzed with Atheris, plus an end-to-end test with an attacker node in a simulated LAN. Written with an AI coding assistant; I reviewed every change.

Code: https://github.com/TonyD365/lanpair · pip install "lanpair[all]"