👉 🇧🇷 🇵🇹 Português
👉 🇺🇸 🇬🇧 English
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.
-
🐍 Python 3
-
🔐 cryptography (Fernet)
-
🖧 socket
-
📦 python-dotenv
client.py # Envia dados criptografados
server.py # Recebe e responde criptografado
.env # Chave secreta FERNET_KEYGerar chave:
from cryptography.fernet import Fernet
print(Fernet.generate_key().decode())No .env ponha sua chave:
FERNET_KEY=sua_chave_aquipip install cryptography python-dotenvApós isso rode o servidor primeiramente para depois rodar o cliente
📡 Cliente → 🔒 Criptografa → 📤 Envia → 🖥️ Servidor → 🔓 Descriptografa → ✅ Responde
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.
-
🐍 Python 3
-
🔐 cryptography (Fernet)
-
🖧 socket
-
📦 python-dotenv
client.py # Sends encrypted data
server.py # Receives and responds with encrypted data
.env # Secret FERNET_KEY
Generate a key:
from cryptography.fernet import Fernet
print(Fernet.generate_key().decode())Add your key to .env:
FERNET_KEY=your_key_herepip install cryptography python-dotenv📡 Client → 🔒 Encrypts → 📤 Sends → 🖥️ Server → 🔓 Decrypts → ✅ Responds