Closed kojix2 closed 6 days ago
Feel free to correct me if you have a better way to write this.
As always, this change is void if there's no spec to ensure its functionality. We'll need at least one example with an invalid CRC and a test to ensure it raises.
Capturing the header bytes in an array seems very inefficient. It also shouldn't be necessary to do in one go.
Instead of passing the entire data to CRC32.checksum
, we can update the checksum with individual bytes or slices as we read them. The result should be identical.
We can either instantiate the CRC32
class and append data bits, or use the .initial
and .update
class methods. The latter is used in the Gzip::Reader
and Gzip::Writer
implementations, for example.
I wrote code to check the value of CRC16 if the Gzip header flag contains an HCRC.
This solves part of #14789