use crc-32 rather than crc module#28
Merged
Merged
Conversation
DonBrinn
commented
Nov 18, 2020
| const checksum = new CRC32Stream(); | ||
| const deadend = new DeadEndStream(); | ||
|
|
||
| const expectedChecksumValue = crc32.buf([157, 10, 217, 109, 100, 200, 300]) >>> 0; |
Contributor
Author
There was a problem hiding this comment.
The value here is the same whether using the crc module or crc-32 module.
DonBrinn
commented
Nov 18, 2020
| const expectedChecksumValue = crc32.buf([157, 10, 217, 109, 100, 200, 300]) >>> 0; | ||
|
|
||
| checksum.on('end', function() { | ||
| assert.equal(checksum.digest().readUInt32BE(0), expectedChecksumValue); |
Contributor
Author
There was a problem hiding this comment.
This test fails if the product code is using the crc module.
ctalkington
approved these changes
Nov 19, 2020
|
Hi @DonBrinn, I believe this is the expected behavior. The default initial value for CRC32 is I've also verified this with Ruby: require 'zlib'
puts("no initial value : #{(Zlib::crc32('helloworld')).to_s(16)}")
puts("with initial value : #{Zlib::crc32('world', Zlib::crc32('hello')).to_s(16)}")
>
no initial value : f9eb20ad
with initial value : f9eb20adThe same output is produced by const together = crc32(Buffer.from('helloworld'));
let separately = crc32(Buffer.from('hello'));
separately = crc32(Buffer.from('world'), separately);
expect(separately).to.equal(together);
console.log({
crc: crc32.model,
together: together.toString(16),
separately: separately.toString(16),
});
>
{ crc: 'crc-32', together: 'f9eb20ad', separately: 'f9eb20ad' } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
0.0is a legitimate checksum value, but that module handles it incorrectly.