satazor / js-spark-md5

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

Getting the same md5 regardless of Blob contents #23

Closed silverbucket closed 9 years ago

silverbucket commented 9 years ago

Not sure what I'm doing wrong here, following the documentation I do something like this:

var img = document.getElementById('image');
var imgBlob = base64ToBlob(getBase64Image(img));

var spark = new SparkMD5.ArrayBuffer();
spark.append(imgBlob);
console.log('md5: ' + spark.end());

No matter which image I use as the test, I always get the md5: d0ad09ba8fe3801ac437d06ba62740d2

From the filesystem, I get the md5:

$ md5 test_image.png 
MD5 (test_image.png) = d1a87269a70cb65ed4a41d272d376052

I've also tried with:

SparkMD5.ArrayBuffer.hash(imgBlob, false);
"d41d8cd98f00b204e9800998ecf8427e"

Which always returns that md5 no matter which test image I use.

The same happens when I use a more complicated example with transferred files (non-images), I get the same md5 sum that I get here with the images.

Any idea what I'm doing wrong here?

silverbucket commented 9 years ago

Nevermind, this was a user error.