Skip to content

A server-client python script to understand how TCP/IP connections work, I used criptography also in this journey

Notifications You must be signed in to change notification settings

natanleal1/serverClientCripto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌍 Select a Language / Selecione uma Linguagem

👉 🇧🇷 🇵🇹 Português
👉 🇺🇸 🇬🇧 English

Português 🇧🇷 🇵🇹

🔐 Comunicação Segura com Sockets em Python

Este projeto mostra como criar uma comunicação Cliente ↔ Servidor em Python usando sockets e criptografia simétrica (Fernet). O cliente gera dados simulados (🌡️ temperatura e 💧 umidade), criptografa a mensagem e envia ao servidor. O servidor recebe, descriptografa, exibe a informação e responde de volta também de forma criptografada.

👉 Assim garantimos que os dados trocados não possam ser lidos por terceiros, mesmo que alguém intercepte a conexão.


⚙️ Tecnologias

  • 🐍 Python 3

  • 🔐 cryptography (Fernet)

  • 🖧 socket

  • 📦 python-dotenv


📂 Estrutura

client.py     # Envia dados criptografados
server.py     # Recebe e responde criptografado
.env          # Chave secreta FERNET_KEY

🔑 Configuração

Gerar chave:

from cryptography.fernet import Fernet
print(Fernet.generate_key().decode())

No .env ponha sua chave:

FERNET_KEY=sua_chave_aqui

🚀 Uso

1. Instale libs:

pip install cryptography python-dotenv

Após isso rode o servidor primeiramente para depois rodar o cliente


📜 Fluxo

📡 Cliente → 🔒 Criptografa → 📤 Envia → 🖥️ Servidor → 🔓 Descriptografa → ✅ Responde



ENGLISH 🇺🇸 🇬🇧

🔐 Secure Socket Communication in Python

This project demonstrates how to create a Client ↔ Server communication in Python using sockets and symmetric encryption (Fernet). The client generates simulated data (🌡️ temperature and 💧 humidity), encrypts the message, and sends it to the server. The server receives, decrypts, displays the information, and responds back also in an encrypted form.

👉 This ensures that the exchanged data cannot be read by third parties, even if the connection is intercepted.


⚙️ Technologies

  • 🐍 Python 3

  • 🔐 cryptography (Fernet)

  • 🖧 socket

  • 📦 python-dotenv


📂 Structure

client.py     # Sends encrypted data
server.py     # Receives and responds with encrypted data
.env          # Secret FERNET_KEY

🔑 Setup

Generate a key:

from cryptography.fernet import Fernet
print(Fernet.generate_key().decode())

Add your key to .env:

FERNET_KEY=your_key_here

🚀 Usage

1. Install dependencies:

pip install cryptography python-dotenv

2.Run the server first, then the client


📜 Flow

📡 Client → 🔒 Encrypts → 📤 Sends → 🖥️ Server → 🔓 Decrypts → ✅ Responds

About

A server-client python script to understand how TCP/IP connections work, I used criptography also in this journey

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages