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

Compressed files MD5 is not calculated properly #30

Closed vjustin closed 8 years ago

vjustin commented 8 years ago

When i try to get the compressed files MD5 value its different from the value I'm getting from Java / Windows / C# MD5 calculated value. Could you please fix and let me know when its ready.

Thanks, Viji

satazor commented 8 years ago

By compressed you mean the minified spark file?

vjustin commented 8 years ago

No. zipped file or FFU file which is compressed.

Thanks Viji

-----Original Message----- From: "André Cruz" notifications@github.com Sent: ‎28/‎10/‎2015 21:25 To: "satazor/SparkMD5" SparkMD5@noreply.github.com Cc: "vjustin" vijihealthbai@gmail.com Subject: Re: [SparkMD5] Compressed files MD5 is not calculated properly (#30)

By compresses you mean the minified spark file? — Reply to this email directly or view it on GitHub.

vjustin commented 8 years ago

Hi,

Did you find the reason why Hash value is not getting generated properly even if we change the file extension of the same file into different extension?

I'm looking forward to hear from you.

One more kind request, could you please change the License terms? :)

Thanks, Viji

satazor commented 8 years ago

Could you please attach the file you are using and the expected hash? Thanks

vjustin commented 8 years ago

Thanks for your response

For example , in the below file i have converted from dll file to png file by changing the extension alone. C# gives the Checksum as below. "fileName":"prm0001Copied.png" Actual When i change extension as png : "Zhqok3pupW35fBaTFgM3GA==" Actual When i change extension as txt : "g/muHIIt52Ifi2hz1rnECQ==" (same file) Expected "checksum_value" : "sZSohF0aIWqvnLh/R/ZTrw==" (Its a MD5 checksum into HEX value. )

Script I used to Convert to HEX

function convert(str) { return btoa(String.fromCharCode.apply(null, str.replace(/\r|\n/g, "").replace(/([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" ")) ); }

The main point here is when ever i change the extension of the file the hash value changes and i'm getting different checksum value as a result.

Note : 4 appends with 4 MB chunks

Thanks, Viji

I can send you the file by email as its not allowing me to upload more than 10 MB , as my test file has 4 chunks to calculate hash.

vjustin commented 8 years ago

I could not send you the file by email as well.

Could you please check any file which is around 16 MB. And try to append as 4 MB chunks. and Get the MD5 values for the same file by changing the extension alone please.

Thanks a lot.

Regards, Viji

vjustin commented 8 years ago

Hi ,

Did you have look at this issue. Were u able to reproduce?

Regards, Viji

silverbucket commented 8 years ago

@vjustin you can really improve readability when referencing code by using 3 ``` (backticks) before and after your code:

  ```javascript
    function () {
      ...
    }
  \`\`\`

It's hard to show you, but you can try reading this guide: https://guides.github.com/features/mastering-markdown/

vjustin commented 8 years ago

Hi ,

Sorry about the readability issue. But if you check only the md5 hash generated values from the original file before and after changing the file extension you can get the the different MD5 , but that should not be the case.

Thanks Viji

-----Original Message----- From: "Nick Jennings" notifications@github.com Sent: ‎02/‎11/‎2015 17:09 To: "satazor/SparkMD5" SparkMD5@noreply.github.com Cc: "vjustin" vijihealthbai@gmail.com Subject: Re: [SparkMD5] Compressed files MD5 is not calculated properly (#30)

@vjustin you can really improve readability when referencing code by using 3 ``` (backticks) before and after your code:

    function () {
      ...
    }
—
Reply to this email directly or view it on GitHub.
satazor commented 8 years ago

@vjustin not yet, I will check later at night.

satazor commented 8 years ago

I've made a test using the file reader example. I've tested using a wav file of ~40MB and then changed the extension to png. Got same results:

screen shot 2015-11-02 at 18 09 05

Are you using the most up to date version of SparkMD5?

vjustin commented 8 years ago

Thanks for this.

I have used latest version available in tag.

I have tested by changing from DLL into text. Also my chunk size was 4 mb. I can try with wave files and smaller chunks tomorrow.

Thanks a lot.

Regards Viji

-----Original Message----- From: "André Cruz" notifications@github.com Sent: ‎02/‎11/‎2015 20:10 To: "satazor/SparkMD5" SparkMD5@noreply.github.com Cc: "vjustin" vijihealthbai@gmail.com Subject: Re: [SparkMD5] Compressed files MD5 is not calculated properly (#30)

I've made a test using the file reader example. I've tested using a wav file and then changed the extension to png. Got same results:

Are you using the most up to date version of SparkMD5? — Reply to this email directly or view it on GitHub.

vjustin commented 8 years ago

Hi , I have tested in your demo URL with my files by changing extension and compressed files as well. Its creating MD5 value consistent and right one.

I forgot to tell you that I have implemented multi threading on top of SparkMD5 and since the order of the execution is not in asc order all the time its causing an issue.

I'll try to fix it from my side on the order of execution, so that this MD5 calculation won't go wrong.

Thanks a lot for your quick responses and time.

I would really appreciate if you could update the license terms.

Regards, Viji

satazor commented 8 years ago

What do you see wrong in the license?

vjustin commented 8 years ago

I could understand its a open license. But the words can be used as normal license terms. So that I can refer the license terms with my team.

Thanks Viji

-----Original Message----- From: "André Cruz" notifications@github.com Sent: ‎03/‎11/‎2015 17:03 To: "satazor/SparkMD5" SparkMD5@noreply.github.com Cc: "vjustin" vijihealthbai@gmail.com Subject: Re: [SparkMD5] Compressed files MD5 is not calculated properly (#30)

What do you see wrong in the license? — Reply to this email directly or view it on GitHub.

satazor commented 8 years ago

I've added an alternative license, see: https://github.com/satazor/SparkMD5#license