← All Exercises
CRC-32 Checksum with Table Lookup
intermediatejavascript
Background
CRC-32 detects burst errors up to 32 bits and accidental edits, guarding Ethernet frames, ZIP entries, and gzip streams. The table-driven form processes one byte per iteration.
Problem
Compute CRC-32 with the reflected polynomial 0xEDB88320. Build the 256-entry table by iterating each index eight times with the conditional XOR, then process the message bytes through the register starting at 0xFFFFFFFF, XORing each byte into the low end, and finish by inverting the register. Output the checksum as eight uppercase hex digits.
Input
A JSON object {"text": string}.Output
A JSON object {"crc": string} of exactly eight uppercase hex characters.Sample tests
Sample 1
Input: {"text":"hello"}Expected: {"crc":"3610A686"}Sample 2
Input: {"text":"The quick brown fox jumps over the lazy dog"}Expected: {"crc":"414FA339"}Sample 3
Input: {"text":""}Expected: {"crc":"00000000"}Your solution
Learning objective
Understand reflected CRC computation, table generation, and hex formatting of 32-bit values.