There is a defect in the crc module used.
Because of that underlying defect, writing the same list of bytes to crc32-stream can result in a different checksum value depending on how the list of bytes is split across different stream.write() calls.
Consider the following:
const checksum = new CRC32Stream();
const deadend = new DeadEndStream();
checksum.on('end', function() {
console.log(checksum.digest().readUInt32BE(0);
done();
});
checksum.write(Buffer.from([157, 10, 217, 109]));
checksum.write(Buffer.from([100, 200, 300]));
checksum.end();
checksum.pipe(deadend);
and
const checksum = new CRC32Stream();
const deadend = new DeadEndStream();
checksum.on('end', function() {
console.log(checksum.digest().readUInt32BE(0);
done();
});
checksum.write(Buffer.from([157, 10, 217, 109, 100, 200, 300]));
checksum.end();
checksum.pipe(deadend);
Those should result in the same checksum value, but the first snippet results in a checksum value of 2178592166 (which is incorrect) and the second snippet results in a checksum value of 2170850123 (which is correct).
Suggested fix: Switch to using the crc-32 module instead.
There is a defect in the crc module used.
Because of that underlying defect, writing the same list of bytes to crc32-stream can result in a different checksum value depending on how the list of bytes is split across different stream.write() calls.
Consider the following:
and
Those should result in the same checksum value, but the first snippet results in a checksum value of
2178592166(which is incorrect) and the second snippet results in a checksum value of2170850123(which is correct).Suggested fix: Switch to using the
crc-32module instead.