satazor / js-spark-md5

Lightning fast normal and incremental md5 for javascript
Do What The F*ck You Want To Public License
2.49k stars 467 forks source link

Incremental MD5 needs increments of certain size #29

Closed asokani closed 9 years ago

asokani commented 9 years ago

Maybe it is obvious to others, but I fell into this trap today and it took some time to find out the real reason.

See this example: https://jsfiddle.net/99Lxy7yx/1/ and choose any file over 10k in size. The computed MD5 is wrong See this: https://jsfiddle.net/99Lxy7yx/4/ and again the same file. The MD5 is fine. Just because the chunk size is multiple of 8 (??)

This should be mentioned somewhere in the docs.

satazor commented 9 years ago

The chunk size should not matter because internally we slice and preserve the rest. It sounds like a bug or a bad usage, but cant look at it because I'm on vacations

asokani commented 9 years ago

No problem, the workaround works. Enjoy your vacations and take a look when ready. That JSFiddle sample is copy-pasted right from the docs, the only difference is the "chunkSize = 10000" line. "chunkSize = 10000" is bad, "chunkSize = 0x1000" is ok.

satazor commented 9 years ago

Fixed in 1.0.1, can you try it and report back?

asokani commented 9 years ago

Great, confirming it is fixed. Thanks!