DEV Community

Raghava Chellu
Raghava Chellu

Posted on

netcrypt: Secure Socket Communication & Encrypted Tunneling for Python

Overview

In today’s distributed systems and cloud-native apps, data-in-transit security is no longer optional — it’s mandatory. Whether you’re sending files, running IoT services, or just building a secure messaging protocol, you need encryption that’s easy to set up and hard to break.

That’s why I built netcrypt, a Python library for encrypted sockets and tunneling. It combines the simplicity of Python sockets with the strength of AES and RSA encryption, making it easier than ever to secure your networked applications.

Features

  • AES & Fernet Encryption — fast symmetric encryption for secure data-in-transit.
  • RSA Key Generation — asymmetric encryption support for key exchange & signing.
  • Encrypted TCP Sockets — secure client-server communication with minimal boilerplate.
  • Secure Tunneling — simple CLI to spin up encrypted tunnels (client/server).
  • Threaded Mode — run tunnels in the background for persistent services.
  • CLI Tools — manage keys, tunnels, and sessions directly from the terminal.

Installation

pip install netcrypt
Enter fullscreen mode Exit fullscreen mode

Usage Examples

Generate AES Key
netcrypt keygen --generate --keyfile aes.key
Enter fullscreen mode Exit fullscreen mode

Start a Secure Tunnel

Server:

netcrypt tunnel --mode server --keyfile aes.key --host 0.0.0.0 --port 9000
Enter fullscreen mode Exit fullscreen mode
Client:

netcrypt tunnel --mode client --keyfile aes.key --host 127.0.0.1 --port 9000
Enter fullscreen mode Exit fullscreen mode

Generate RSA Key Pair

netcrypt rsagen --out-private rsa_private.pem --out-public rsa_public.pem
Enter fullscreen mode Exit fullscreen mode

Project Structure

netcrypt/
├── encryptors.py     # AES, RSA, Fernet encryption logic
├── key_manager.py    # Key handling & persistence
├── sockets.py        # Secure socket wrappers
├── tunnel.py         # Encrypted tunnel orchestration
├── cli.py            # Command-line interface
└── __init__.py
Enter fullscreen mode Exit fullscreen mode

Run Tests

pytest tests/
Enter fullscreen mode Exit fullscreen mode

Why Use netcrypt?

  • Secure-by-default — avoids insecure defaults, ships with AES-256 and RSA baked in.
  • Developer-friendly — run tunnels or manage keys with one-liners.
  • Lightweight — no heavy external dependencies, just clean Python.
  • Versatile — works for IoT devices, cloud services, or local dev setups.

License

MIT © 2025 Raghava Chellu
Enter fullscreen mode Exit fullscreen mode

Installation

pip install netcrypt

Enter fullscreen mode Exit fullscreen mode

Top comments (0)