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

Giving -ve CheckSum for formData. #2

Closed
deepak4u2006 opened this issue May 8, 2017 · 2 comments
Closed

Giving -ve CheckSum for formData. #2

deepak4u2006 opened this issue May 8, 2017 · 2 comments

Comments

@deepak4u2006
Copy link

deepak4u2006 commented May 8, 2017

Hi I am using this library in my current project. It gives perfect checksum for the Test Strings, but in my real scenario I need to calculate the checksum of my formdata.
A typical formdata will be like;
var ADLER32 = require('adler-32'); let checkSum = ADLER32.str("formdata={\"data\":\"value\", \"key\":\"value1\", \"key2\":\"value2\"}123456");

I get a negative checksum for this input. -1415900241

for let checkSum = ADLER32.str("SheetJS");
I get proper checksum Value. 176947863

Hoping to get a solution !!!

@SheetJSDev
Copy link
Contributor

@deepak4u2006 it is explained in the README:

The return value is a signed 32-bit integer.

If you need the unsigned value, convert to unsigned integer with >>>0:

var ADLER32 = require('adler-32');
let checkSum = ADLER32.str("formdata={\"data\":\"value\", \"key\":\"value1\", \"key2\":\"value2\"}123456") >>> 0;

Note that the web demo displays both types: http://oss.sheetjs.com/js-adler32/

adler32sign

That page uses the >>>0 trick to generate the unsigned value

@deepak4u2006
Copy link
Author

@SheetJSDev Thanks for the quickest reply ever possible.
adding >>>0 worked like a dream.

Thanks again!!! 👍

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