md5_worker.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. "use strict";
  2. // Hashes any blob
  3. var Md5FileHasher = /** @class */ (function () {
  4. function Md5FileHasher(_callback, // Callback to return the result
  5. _async, // Async version is not always available in a web worker
  6. _partSize) {
  7. if (_async === void 0) { _async = true; }
  8. if (_partSize === void 0) { _partSize = 1048576; }
  9. this._callback = _callback;
  10. this._async = _async;
  11. this._partSize = _partSize;
  12. this._configureReader();
  13. }
  14. /**
  15. * Hash a blob of data in the worker
  16. * @param blob Data to hash
  17. */
  18. Md5FileHasher.prototype.hash = function (blob) {
  19. var self = this;
  20. self._blob = blob;
  21. // self._length = Math.ceil(blob.size / self._partSize);
  22. self._part = 0;
  23. self._md5 = new Md5();
  24. self._processPart();
  25. };
  26. Md5FileHasher.prototype._fail = function () {
  27. this._callback({
  28. success: false,
  29. result: 'data read failed'
  30. });
  31. };
  32. Md5FileHasher.prototype._hashData = function (e) {
  33. var self = this;
  34. self._md5.appendByteArray(new Uint8Array(e.target.result));
  35. if (self._part * self._partSize >= self._blob.size) {
  36. self._callback({
  37. success: true,
  38. result: self._md5.end()
  39. });
  40. }
  41. else {
  42. self._processPart();
  43. }
  44. };
  45. Md5FileHasher.prototype._processPart = function () {
  46. var self = this;
  47. var endbyte = 0;
  48. var current_part;
  49. self._part += 1;
  50. if (self._blob.size > self._partSize) { // If blob bigger then part_size we will slice it up
  51. endbyte = self._part * self._partSize;
  52. if (endbyte > self._blob.size) {
  53. endbyte = self._blob.size;
  54. }
  55. current_part = self._blob.slice((self._part - 1) * self._partSize, endbyte);
  56. }
  57. else {
  58. current_part = self._blob;
  59. }
  60. if (self._async) {
  61. self._reader.readAsArrayBuffer(current_part);
  62. }
  63. else {
  64. setTimeout(function () {
  65. try {
  66. self._hashData({
  67. target: {
  68. result: self._reader.readAsArrayBuffer(current_part)
  69. },
  70. });
  71. }
  72. catch (e) {
  73. self._fail();
  74. }
  75. }, 0);
  76. }
  77. };
  78. Md5FileHasher.prototype._configureReader = function () {
  79. var self = this;
  80. if (self._async) {
  81. self._reader = new FileReader();
  82. self._reader.onload = self._hashData.bind(self);
  83. self._reader.onerror = self._fail.bind(self);
  84. self._reader.onabort = self._fail.bind(self);
  85. }
  86. else {
  87. self._reader = new FileReaderSync();
  88. }
  89. };
  90. return Md5FileHasher;
  91. }());
  92. //# sourceMappingURL=md5_file_hasher.js.map"use strict";
  93. /*
  94. TypeScript Md5
  95. ==============
  96. Based on work by
  97. * Joseph Myers: http://www.myersdaily.org/joseph/javascript/md5-text.html
  98. * André Cruz: https://github.com/satazor/SparkMD5
  99. * Raymond Hill: https://github.com/gorhill/yamd5.js
  100. Effectively a TypeScrypt re-write of Raymond Hill JS Library
  101. The MIT License (MIT)
  102. Copyright (C) 2014 Raymond Hill
  103. Permission is hereby granted, free of charge, to any person obtaining a copy
  104. of this software and associated documentation files (the "Software"), to deal
  105. in the Software without restriction, including without limitation the rights
  106. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  107. copies of the Software, and to permit persons to whom the Software is
  108. furnished to do so, subject to the following conditions:
  109. The above copyright notice and this permission notice shall be included in
  110. all copies or substantial portions of the Software.
  111. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  112. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  113. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  114. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  115. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  116. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  117. THE SOFTWARE.
  118. DO WHAT YOU WANT TO PUBLIC LICENSE
  119. Version 2, December 2004
  120. Copyright (C) 2015 André Cruz <amdfcruz@gmail.com>
  121. Everyone is permitted to copy and distribute verbatim or modified
  122. copies of this license document, and changing it is allowed as long
  123. as the name is changed.
  124. DO WHAT YOU WANT TO PUBLIC LICENSE
  125. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  126. 0. You just DO WHAT YOU WANT TO.
  127. */
  128. ;
  129. var Md5 = /** @class */ (function () {
  130. function Md5() {
  131. this._dataLength = 0;
  132. this._bufferLength = 0;
  133. this._state = new Int32Array(4);
  134. this._buffer = new ArrayBuffer(68);
  135. this._buffer8 = new Uint8Array(this._buffer, 0, 68);
  136. this._buffer32 = new Uint32Array(this._buffer, 0, 17);
  137. this.start();
  138. }
  139. Md5.hashStr = function (str, raw) {
  140. if (raw === void 0) { raw = false; }
  141. return this.onePassHasher
  142. .start()
  143. .appendStr(str)
  144. .end(raw);
  145. };
  146. Md5.hashAsciiStr = function (str, raw) {
  147. if (raw === void 0) { raw = false; }
  148. return this.onePassHasher
  149. .start()
  150. .appendAsciiStr(str)
  151. .end(raw);
  152. };
  153. Md5._hex = function (x) {
  154. var hc = Md5.hexChars;
  155. var ho = Md5.hexOut;
  156. var n;
  157. var offset;
  158. var j;
  159. var i;
  160. for (i = 0; i < 4; i += 1) {
  161. offset = i * 8;
  162. n = x[i];
  163. for (j = 0; j < 8; j += 2) {
  164. ho[offset + 1 + j] = hc.charAt(n & 0x0F);
  165. n >>>= 4;
  166. ho[offset + 0 + j] = hc.charAt(n & 0x0F);
  167. n >>>= 4;
  168. }
  169. }
  170. return ho.join('');
  171. };
  172. Md5._md5cycle = function (x, k) {
  173. var a = x[0];
  174. var b = x[1];
  175. var c = x[2];
  176. var d = x[3];
  177. // ff()
  178. a += (b & c | ~b & d) + k[0] - 680876936 | 0;
  179. a = (a << 7 | a >>> 25) + b | 0;
  180. d += (a & b | ~a & c) + k[1] - 389564586 | 0;
  181. d = (d << 12 | d >>> 20) + a | 0;
  182. c += (d & a | ~d & b) + k[2] + 606105819 | 0;
  183. c = (c << 17 | c >>> 15) + d | 0;
  184. b += (c & d | ~c & a) + k[3] - 1044525330 | 0;
  185. b = (b << 22 | b >>> 10) + c | 0;
  186. a += (b & c | ~b & d) + k[4] - 176418897 | 0;
  187. a = (a << 7 | a >>> 25) + b | 0;
  188. d += (a & b | ~a & c) + k[5] + 1200080426 | 0;
  189. d = (d << 12 | d >>> 20) + a | 0;
  190. c += (d & a | ~d & b) + k[6] - 1473231341 | 0;
  191. c = (c << 17 | c >>> 15) + d | 0;
  192. b += (c & d | ~c & a) + k[7] - 45705983 | 0;
  193. b = (b << 22 | b >>> 10) + c | 0;
  194. a += (b & c | ~b & d) + k[8] + 1770035416 | 0;
  195. a = (a << 7 | a >>> 25) + b | 0;
  196. d += (a & b | ~a & c) + k[9] - 1958414417 | 0;
  197. d = (d << 12 | d >>> 20) + a | 0;
  198. c += (d & a | ~d & b) + k[10] - 42063 | 0;
  199. c = (c << 17 | c >>> 15) + d | 0;
  200. b += (c & d | ~c & a) + k[11] - 1990404162 | 0;
  201. b = (b << 22 | b >>> 10) + c | 0;
  202. a += (b & c | ~b & d) + k[12] + 1804603682 | 0;
  203. a = (a << 7 | a >>> 25) + b | 0;
  204. d += (a & b | ~a & c) + k[13] - 40341101 | 0;
  205. d = (d << 12 | d >>> 20) + a | 0;
  206. c += (d & a | ~d & b) + k[14] - 1502002290 | 0;
  207. c = (c << 17 | c >>> 15) + d | 0;
  208. b += (c & d | ~c & a) + k[15] + 1236535329 | 0;
  209. b = (b << 22 | b >>> 10) + c | 0;
  210. // gg()
  211. a += (b & d | c & ~d) + k[1] - 165796510 | 0;
  212. a = (a << 5 | a >>> 27) + b | 0;
  213. d += (a & c | b & ~c) + k[6] - 1069501632 | 0;
  214. d = (d << 9 | d >>> 23) + a | 0;
  215. c += (d & b | a & ~b) + k[11] + 643717713 | 0;
  216. c = (c << 14 | c >>> 18) + d | 0;
  217. b += (c & a | d & ~a) + k[0] - 373897302 | 0;
  218. b = (b << 20 | b >>> 12) + c | 0;
  219. a += (b & d | c & ~d) + k[5] - 701558691 | 0;
  220. a = (a << 5 | a >>> 27) + b | 0;
  221. d += (a & c | b & ~c) + k[10] + 38016083 | 0;
  222. d = (d << 9 | d >>> 23) + a | 0;
  223. c += (d & b | a & ~b) + k[15] - 660478335 | 0;
  224. c = (c << 14 | c >>> 18) + d | 0;
  225. b += (c & a | d & ~a) + k[4] - 405537848 | 0;
  226. b = (b << 20 | b >>> 12) + c | 0;
  227. a += (b & d | c & ~d) + k[9] + 568446438 | 0;
  228. a = (a << 5 | a >>> 27) + b | 0;
  229. d += (a & c | b & ~c) + k[14] - 1019803690 | 0;
  230. d = (d << 9 | d >>> 23) + a | 0;
  231. c += (d & b | a & ~b) + k[3] - 187363961 | 0;
  232. c = (c << 14 | c >>> 18) + d | 0;
  233. b += (c & a | d & ~a) + k[8] + 1163531501 | 0;
  234. b = (b << 20 | b >>> 12) + c | 0;
  235. a += (b & d | c & ~d) + k[13] - 1444681467 | 0;
  236. a = (a << 5 | a >>> 27) + b | 0;
  237. d += (a & c | b & ~c) + k[2] - 51403784 | 0;
  238. d = (d << 9 | d >>> 23) + a | 0;
  239. c += (d & b | a & ~b) + k[7] + 1735328473 | 0;
  240. c = (c << 14 | c >>> 18) + d | 0;
  241. b += (c & a | d & ~a) + k[12] - 1926607734 | 0;
  242. b = (b << 20 | b >>> 12) + c | 0;
  243. // hh()
  244. a += (b ^ c ^ d) + k[5] - 378558 | 0;
  245. a = (a << 4 | a >>> 28) + b | 0;
  246. d += (a ^ b ^ c) + k[8] - 2022574463 | 0;
  247. d = (d << 11 | d >>> 21) + a | 0;
  248. c += (d ^ a ^ b) + k[11] + 1839030562 | 0;
  249. c = (c << 16 | c >>> 16) + d | 0;
  250. b += (c ^ d ^ a) + k[14] - 35309556 | 0;
  251. b = (b << 23 | b >>> 9) + c | 0;
  252. a += (b ^ c ^ d) + k[1] - 1530992060 | 0;
  253. a = (a << 4 | a >>> 28) + b | 0;
  254. d += (a ^ b ^ c) + k[4] + 1272893353 | 0;
  255. d = (d << 11 | d >>> 21) + a | 0;
  256. c += (d ^ a ^ b) + k[7] - 155497632 | 0;
  257. c = (c << 16 | c >>> 16) + d | 0;
  258. b += (c ^ d ^ a) + k[10] - 1094730640 | 0;
  259. b = (b << 23 | b >>> 9) + c | 0;
  260. a += (b ^ c ^ d) + k[13] + 681279174 | 0;
  261. a = (a << 4 | a >>> 28) + b | 0;
  262. d += (a ^ b ^ c) + k[0] - 358537222 | 0;
  263. d = (d << 11 | d >>> 21) + a | 0;
  264. c += (d ^ a ^ b) + k[3] - 722521979 | 0;
  265. c = (c << 16 | c >>> 16) + d | 0;
  266. b += (c ^ d ^ a) + k[6] + 76029189 | 0;
  267. b = (b << 23 | b >>> 9) + c | 0;
  268. a += (b ^ c ^ d) + k[9] - 640364487 | 0;
  269. a = (a << 4 | a >>> 28) + b | 0;
  270. d += (a ^ b ^ c) + k[12] - 421815835 | 0;
  271. d = (d << 11 | d >>> 21) + a | 0;
  272. c += (d ^ a ^ b) + k[15] + 530742520 | 0;
  273. c = (c << 16 | c >>> 16) + d | 0;
  274. b += (c ^ d ^ a) + k[2] - 995338651 | 0;
  275. b = (b << 23 | b >>> 9) + c | 0;
  276. // ii()
  277. a += (c ^ (b | ~d)) + k[0] - 198630844 | 0;
  278. a = (a << 6 | a >>> 26) + b | 0;
  279. d += (b ^ (a | ~c)) + k[7] + 1126891415 | 0;
  280. d = (d << 10 | d >>> 22) + a | 0;
  281. c += (a ^ (d | ~b)) + k[14] - 1416354905 | 0;
  282. c = (c << 15 | c >>> 17) + d | 0;
  283. b += (d ^ (c | ~a)) + k[5] - 57434055 | 0;
  284. b = (b << 21 | b >>> 11) + c | 0;
  285. a += (c ^ (b | ~d)) + k[12] + 1700485571 | 0;
  286. a = (a << 6 | a >>> 26) + b | 0;
  287. d += (b ^ (a | ~c)) + k[3] - 1894986606 | 0;
  288. d = (d << 10 | d >>> 22) + a | 0;
  289. c += (a ^ (d | ~b)) + k[10] - 1051523 | 0;
  290. c = (c << 15 | c >>> 17) + d | 0;
  291. b += (d ^ (c | ~a)) + k[1] - 2054922799 | 0;
  292. b = (b << 21 | b >>> 11) + c | 0;
  293. a += (c ^ (b | ~d)) + k[8] + 1873313359 | 0;
  294. a = (a << 6 | a >>> 26) + b | 0;
  295. d += (b ^ (a | ~c)) + k[15] - 30611744 | 0;
  296. d = (d << 10 | d >>> 22) + a | 0;
  297. c += (a ^ (d | ~b)) + k[6] - 1560198380 | 0;
  298. c = (c << 15 | c >>> 17) + d | 0;
  299. b += (d ^ (c | ~a)) + k[13] + 1309151649 | 0;
  300. b = (b << 21 | b >>> 11) + c | 0;
  301. a += (c ^ (b | ~d)) + k[4] - 145523070 | 0;
  302. a = (a << 6 | a >>> 26) + b | 0;
  303. d += (b ^ (a | ~c)) + k[11] - 1120210379 | 0;
  304. d = (d << 10 | d >>> 22) + a | 0;
  305. c += (a ^ (d | ~b)) + k[2] + 718787259 | 0;
  306. c = (c << 15 | c >>> 17) + d | 0;
  307. b += (d ^ (c | ~a)) + k[9] - 343485551 | 0;
  308. b = (b << 21 | b >>> 11) + c | 0;
  309. x[0] = a + x[0] | 0;
  310. x[1] = b + x[1] | 0;
  311. x[2] = c + x[2] | 0;
  312. x[3] = d + x[3] | 0;
  313. };
  314. /**
  315. * Initialise buffer to be hashed
  316. */
  317. Md5.prototype.start = function () {
  318. this._dataLength = 0;
  319. this._bufferLength = 0;
  320. this._state.set(Md5.stateIdentity);
  321. return this;
  322. };
  323. // Char to code point to to array conversion:
  324. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
  325. // #Example.3A_Fixing_charCodeAt_to_handle_non-Basic-Multilingual-Plane_characters_if_their_presence_earlier_in_the_string_is_unknown
  326. /**
  327. * Append a UTF-8 string to the hash buffer
  328. * @param str String to append
  329. */
  330. Md5.prototype.appendStr = function (str) {
  331. var buf8 = this._buffer8;
  332. var buf32 = this._buffer32;
  333. var bufLen = this._bufferLength;
  334. var code;
  335. var i;
  336. for (i = 0; i < str.length; i += 1) {
  337. code = str.charCodeAt(i);
  338. if (code < 128) {
  339. buf8[bufLen++] = code;
  340. }
  341. else if (code < 0x800) {
  342. buf8[bufLen++] = (code >>> 6) + 0xC0;
  343. buf8[bufLen++] = code & 0x3F | 0x80;
  344. }
  345. else if (code < 0xD800 || code > 0xDBFF) {
  346. buf8[bufLen++] = (code >>> 12) + 0xE0;
  347. buf8[bufLen++] = (code >>> 6 & 0x3F) | 0x80;
  348. buf8[bufLen++] = (code & 0x3F) | 0x80;
  349. }
  350. else {
  351. code = ((code - 0xD800) * 0x400) + (str.charCodeAt(++i) - 0xDC00) + 0x10000;
  352. if (code > 0x10FFFF) {
  353. throw new Error('Unicode standard supports code points up to U+10FFFF');
  354. }
  355. buf8[bufLen++] = (code >>> 18) + 0xF0;
  356. buf8[bufLen++] = (code >>> 12 & 0x3F) | 0x80;
  357. buf8[bufLen++] = (code >>> 6 & 0x3F) | 0x80;
  358. buf8[bufLen++] = (code & 0x3F) | 0x80;
  359. }
  360. if (bufLen >= 64) {
  361. this._dataLength += 64;
  362. Md5._md5cycle(this._state, buf32);
  363. bufLen -= 64;
  364. buf32[0] = buf32[16];
  365. }
  366. }
  367. this._bufferLength = bufLen;
  368. return this;
  369. };
  370. /**
  371. * Append an ASCII string to the hash buffer
  372. * @param str String to append
  373. */
  374. Md5.prototype.appendAsciiStr = function (str) {
  375. var buf8 = this._buffer8;
  376. var buf32 = this._buffer32;
  377. var bufLen = this._bufferLength;
  378. var i;
  379. var j = 0;
  380. for (;;) {
  381. i = Math.min(str.length - j, 64 - bufLen);
  382. while (i--) {
  383. buf8[bufLen++] = str.charCodeAt(j++);
  384. }
  385. if (bufLen < 64) {
  386. break;
  387. }
  388. this._dataLength += 64;
  389. Md5._md5cycle(this._state, buf32);
  390. bufLen = 0;
  391. }
  392. this._bufferLength = bufLen;
  393. return this;
  394. };
  395. /**
  396. * Append a byte array to the hash buffer
  397. * @param input array to append
  398. */
  399. Md5.prototype.appendByteArray = function (input) {
  400. var buf8 = this._buffer8;
  401. var buf32 = this._buffer32;
  402. var bufLen = this._bufferLength;
  403. var i;
  404. var j = 0;
  405. for (;;) {
  406. i = Math.min(input.length - j, 64 - bufLen);
  407. while (i--) {
  408. buf8[bufLen++] = input[j++];
  409. }
  410. if (bufLen < 64) {
  411. break;
  412. }
  413. this._dataLength += 64;
  414. Md5._md5cycle(this._state, buf32);
  415. bufLen = 0;
  416. }
  417. this._bufferLength = bufLen;
  418. return this;
  419. };
  420. /**
  421. * Get the state of the hash buffer
  422. */
  423. Md5.prototype.getState = function () {
  424. var s = this._state;
  425. return {
  426. buffer: String.fromCharCode.apply(null, Array.from(this._buffer8)),
  427. buflen: this._bufferLength,
  428. length: this._dataLength,
  429. state: [s[0], s[1], s[2], s[3]]
  430. };
  431. };
  432. /**
  433. * Override the current state of the hash buffer
  434. * @param state New hash buffer state
  435. */
  436. Md5.prototype.setState = function (state) {
  437. var buf = state.buffer;
  438. var x = state.state;
  439. var s = this._state;
  440. var i;
  441. this._dataLength = state.length;
  442. this._bufferLength = state.buflen;
  443. s[0] = x[0];
  444. s[1] = x[1];
  445. s[2] = x[2];
  446. s[3] = x[3];
  447. for (i = 0; i < buf.length; i += 1) {
  448. this._buffer8[i] = buf.charCodeAt(i);
  449. }
  450. };
  451. /**
  452. * Hash the current state of the hash buffer and return the result
  453. * @param raw Whether to return the value as an `Int32Array`
  454. */
  455. Md5.prototype.end = function (raw) {
  456. if (raw === void 0) { raw = false; }
  457. var bufLen = this._bufferLength;
  458. var buf8 = this._buffer8;
  459. var buf32 = this._buffer32;
  460. var i = (bufLen >> 2) + 1;
  461. this._dataLength += bufLen;
  462. var dataBitsLen = this._dataLength * 8;
  463. buf8[bufLen] = 0x80;
  464. buf8[bufLen + 1] = buf8[bufLen + 2] = buf8[bufLen + 3] = 0;
  465. buf32.set(Md5.buffer32Identity.subarray(i), i);
  466. if (bufLen > 55) {
  467. Md5._md5cycle(this._state, buf32);
  468. buf32.set(Md5.buffer32Identity);
  469. }
  470. // Do the final computation based on the tail and length
  471. // Beware that the final length may not fit in 32 bits so we take care of that
  472. if (dataBitsLen <= 0xFFFFFFFF) {
  473. buf32[14] = dataBitsLen;
  474. }
  475. else {
  476. var matches = dataBitsLen.toString(16).match(/(.*?)(.{0,8})$/);
  477. if (matches === null) {
  478. return;
  479. }
  480. var lo = parseInt(matches[2], 16);
  481. var hi = parseInt(matches[1], 16) || 0;
  482. buf32[14] = lo;
  483. buf32[15] = hi;
  484. }
  485. Md5._md5cycle(this._state, buf32);
  486. return raw ? this._state : Md5._hex(this._state);
  487. };
  488. // Private Static Variables
  489. Md5.stateIdentity = new Int32Array([1732584193, -271733879, -1732584194, 271733878]);
  490. Md5.buffer32Identity = new Int32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
  491. Md5.hexChars = '0123456789abcdef';
  492. Md5.hexOut = [];
  493. // Permanent instance is to use for one-call hashing
  494. Md5.onePassHasher = new Md5();
  495. return Md5;
  496. }());
  497. if (Md5.hashStr('hello') !== '5d41402abc4b2a76b9719d911017c592') {
  498. throw new Error('Md5 self test failed.');
  499. }
  500. //# sourceMappingURL=md5.js.map
  501. (function(global) {
  502. // Older versions of Firefox do not have FileReader in webworkers
  503. var async = !!global.FileReader;
  504. // Just in case this is prefixed
  505. if (!Blob.prototype.slice) {
  506. Blob.prototype.slice = Blob.prototype.webkitSlice || Blob.prototype.mozSlice;
  507. }
  508. // Hook-up worker input
  509. global.onmessage = function(e) {
  510. var hasher = new Md5FileHasher(function (data) {
  511. // This prevents an illegal invocation error
  512. global.postMessage(data);
  513. }, async);
  514. hasher.hash(e.data);
  515. };
  516. })(this);