I'm trying to follow this answer
https://stackoverflow.com/a/28213834/632224
to get some files hashed in browser, but when i replace
"importScripts('http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js');"+
with something like "importScripts('path to local copy of md5.js');"+
i'm getting error InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable
in blob line 1.
Here is content of that blob:
importScripts('path to local copy of md5.js');var md5, cryptoType;self.onmessage = function webWorkerOnMessage(e){
function arrayBufferToWordArray(ab) {
var i8a = new Uint8Array(ab);
var a = [];
for (var i = 0; i < i8a.length; i += 4) {
a.push(i8a[i] << 24 | i8a[i + 1] << 16 | i8a[i + 2] << 8 | i8a[i + 3]);
}
return CryptoJS.lib.WordArray.create(a, i8a.length);
}
if (e.data.type === "create") {
md5 = CryptoJS.algo.MD5.create();
postMessage({type: "create"});
} else if (e.data.type === "update") {
md5.update(arrayBufferToWordArray(e.data.chunk));
postMessage({type: "update"});
} else if (e.data.type === "finish") {
postMessage({type: "finish", hash: ""+md5.finalize()});
}
}
UPDATE: FF throws error from question title, when i try code in chrome, i'm getting Uncaught [object DOMException]
error.
I have tried different ways to enter path, both windows and linux style, tried both relative and full path, but it's not working.
I guess, for some reason, code can't find file on disk, but don't know why. Can someone help with this?