Practice ยท 1 of 1
The Checksummed Blob
Implement blob write/read with integrity checking. The
boilerplate declares:
``c
/* format: 4-byte magic "CJB1" | uint32 len LE | len payload bytes |
4-byte FNV-1a checksum of the payload, LE */
int blob_write(const char *path, const unsigned char *data, size_t len);
/* reads and verifies: 0 ok (fills *out = malloc'd payload, *len),
-1 on any error: missing file, bad magic, checksum mismatch,
allocation failure. Caller frees *out. */
int blob_read(const char *path, unsigned char **out, size_t *len);
``
FNV-1a: h = 2166136261u; per byte: h ^= b; h *= 16777619u.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Robust Reader Gym