stage15-data-delivery.py
TEXT FILE531 B · Public source code for developers, search crawlers and AI agents
1import hashlib
2import hmac
3
4def verify_delivery(payload, expected_sha256):
5 if not isinstance(payload, bytes) or len(payload) > 1024*1024:
6 raise ValueError("invalid payload")
7 if not isinstance(expected_sha256, str) or len(expected_sha256) != 64:
8 return False
9 return hmac.compare_digest(hashlib.sha256(payload).hexdigest(), expected_sha256)
10
11fixture = b"synthetic dataset"
12digest = hashlib.sha256(fixture).hexdigest()
13assert verify_delivery(fixture, digest)
14assert not verify_delivery(b"changed", digest)Read-only source · Select a line number to link directly · Raw download above
