Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CRC32_C] Compute result is negative value #3

Open
zjhiphop opened this issue May 5, 2018 · 1 comment
Open

[CRC32_C] Compute result is negative value #3

zjhiphop opened this issue May 5, 2018 · 1 comment

Comments

@zjhiphop
Copy link

zjhiphop commented May 5, 2018

For example:

// for (0-100 hex)
let data = '0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F6061626364';
let buf = Buffer.from(data, 'hex'); 
let crc = CRC.default("CRC32_C");
let computed_crc = crc.compute(source);
// output is: -5DA0519C

But for correct value should be 0xA25FAE64, you can test in website 'http://crccalc.com/' with the same data and 'hex' option selected.

Pls help to check it.

@suria22
Copy link

suria22 commented Sep 26, 2020

let computed_crc = crc.compute(source)>>>0;
Use the Zero fill right shift operator with zero shift. It will convert it to unsigned value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants