feat: Semaine 9

This commit is contained in:
gauvainboiche
2026-05-15 16:24:56 +02:00
parent 3315cb2336
commit ce1f0e513a
108 changed files with 3150 additions and 0 deletions
@@ -0,0 +1,20 @@
import json, hashlib, time
# https://docs.python.org/3/library/json.html
# https://docs.python.org/3/library/hashlib.html
def compute_hash(content):
return hashlib.sha256(content.encode()).hexdigest()
def get_timestamp():
return time.time()
async def send_json(writer, data):
message = f"{json.dumps(data)}\n"
writer.write(message.encode())
await writer.drain()
async def receive_json(reader):
data = await reader.readline()
if not data:
return None
return json.loads(data.decode())