Files
gauvainboiche ce1f0e513a feat: Semaine 9
2026-05-15 16:24:56 +02:00

20 lines
526 B
Python

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())