mirror of
https://github.com/emn178/js-md5.git
synced 2026-08-13 04:44:03 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0263ab835f | ||
|
|
5f0bd5a888 | ||
|
|
cb8eb73ef1 | ||
|
|
24d8eb504d | ||
|
|
a54f102b8a | ||
|
|
e7f1ca7da8 |
@@ -1,2 +0,0 @@
|
|||||||
/node_modules/
|
|
||||||
/tests/
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/node_modules/
|
||||||
|
/coverage/
|
||||||
|
/.nyc_output/
|
||||||
|
/tests/
|
||||||
|
/doc/
|
||||||
|
.covignore
|
||||||
|
.travis.yml
|
||||||
|
.npmignore
|
||||||
|
bower.json
|
||||||
+3
-14
@@ -1,21 +1,10 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "0.12.15"
|
- "6.11.4"
|
||||||
- "4.5"
|
- "8.6.0"
|
||||||
- "6.5.0"
|
|
||||||
before_install:
|
before_install:
|
||||||
- npm install coveralls
|
- npm install coveralls
|
||||||
- npm install mocha-lcov-reporter
|
after_success: npm run coveralls
|
||||||
install:
|
|
||||||
- CXX="g++-4.8" CC="gcc-4.8" npm install
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- gcc-4.8
|
|
||||||
- g++-4.8
|
|
||||||
script: npm run-script coveralls
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|||||||
@@ -1,5 +1,28 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v0.7.3 / 2017-12-18
|
||||||
|
### Fixed
|
||||||
|
- incorrect result when first bit is 1 of bytes. #18
|
||||||
|
|
||||||
|
## v0.7.2 / 2017-10-31
|
||||||
|
### Improved
|
||||||
|
- performance of hBytes increment.
|
||||||
|
|
||||||
|
## v0.7.1 / 2017-10-29
|
||||||
|
### Fixed
|
||||||
|
- incorrect result when file size >= 4G.
|
||||||
|
|
||||||
|
## v0.7.0 / 2017-10-29
|
||||||
|
### Fixed
|
||||||
|
- incorrect result when file size >= 512M.
|
||||||
|
|
||||||
|
## v0.6.1 / 2017-10-07
|
||||||
|
### Fixed
|
||||||
|
- ArrayBuffer.isView issue in IE10.
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- performance of input check.
|
||||||
|
|
||||||
## v0.6.0 / 2017-07-28
|
## v0.6.0 / 2017-07-28
|
||||||
### Added
|
### Added
|
||||||
- support base64 string output.
|
- support base64 string output.
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "js-md5",
|
"name": "js-md5",
|
||||||
"version": "0.6.0",
|
"version": "0.7.3",
|
||||||
"main": ["src/md5.js"],
|
"main": ["src/md5.js"],
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"tests"
|
"tests"
|
||||||
|
|||||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+10
-10
@@ -93,7 +93,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line172">line 172</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line178">line 178</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line566">line 566</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line579">line 579</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line578">line 578</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line591">line 591</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line613">line 613</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line626">line 626</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -568,7 +568,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line600">line 600</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line613">line 613</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -688,7 +688,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line544">line 544</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line557">line 557</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -808,7 +808,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line499">line 499</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line512">line 512</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -928,7 +928,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line532">line 532</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line545">line 545</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -1106,7 +1106,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line200">line 200</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line206">line 206</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -1185,7 +1185,7 @@
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Dec 18 2017 18:48:59 GMT+0800 (CST)
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script> prettyPrint(); </script>
|
<script> prettyPrint(); </script>
|
||||||
|
|||||||
+2
-2
@@ -214,7 +214,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line646">line 646</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line659">line 659</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Dec 18 2017 18:48:59 GMT+0800 (CST)
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script> prettyPrint(); </script>
|
<script> prettyPrint(); </script>
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ md5.base64(''); // 1B2M2Y8AsgTpgAmY7PhCfg==</code></pre><h2>License</h2><p>The p
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Dec 18 2017 18:48:59 GMT+0800 (CST)
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script> prettyPrint(); </script>
|
<script> prettyPrint(); </script>
|
||||||
|
|||||||
+10
-10
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<dt class="tag-version">Version:</dt>
|
<dt class="tag-version">Version:</dt>
|
||||||
<dd class="tag-version"><ul class="dummy"><li>0.6.0</li></ul></dd>
|
<dd class="tag-version"><ul class="dummy"><li>0.7.3</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line68">line 68</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line74">line 74</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -408,7 +408,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line77">line 77</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line83">line 83</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -579,7 +579,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line96">line 96</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line102">line 102</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -752,7 +752,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line86">line 86</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line92">line 92</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -865,7 +865,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line111">line 111</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line117">line 117</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -1036,7 +1036,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line59">line 59</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line65">line 65</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -1207,7 +1207,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line48">line 48</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line54">line 54</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -1380,7 +1380,7 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line119">line 119</a>
|
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line125">line 125</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@@ -1460,7 +1460,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Dec 18 2017 18:48:59 GMT+0800 (CST)
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script> prettyPrint(); </script>
|
<script> prettyPrint(); </script>
|
||||||
|
|||||||
+28
-15
@@ -30,7 +30,7 @@
|
|||||||
* [js-md5]{@link https://github.com/emn178/js-md5}
|
* [js-md5]{@link https://github.com/emn178/js-md5}
|
||||||
*
|
*
|
||||||
* @namespace md5
|
* @namespace md5
|
||||||
* @version 0.6.0
|
* @version 0.7.3
|
||||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||||
* @copyright Chen, Yi-Cyuan 2014-2017
|
* @copyright Chen, Yi-Cyuan 2014-2017
|
||||||
* @license MIT
|
* @license MIT
|
||||||
@@ -73,6 +73,12 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
||||||
|
ArrayBuffer.isView = function (obj) {
|
||||||
|
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method hex
|
* @method hex
|
||||||
* @memberof md5
|
* @memberof md5
|
||||||
@@ -220,7 +226,7 @@
|
|||||||
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = 0;
|
this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;
|
||||||
this.finalized = this.hashed = false;
|
this.finalized = this.hashed = false;
|
||||||
this.first = true;
|
this.first = true;
|
||||||
}
|
}
|
||||||
@@ -238,23 +244,25 @@
|
|||||||
if (this.finalized) {
|
if (this.finalized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var notString = typeof(message) != 'string';
|
|
||||||
if (notString) {
|
var notString, type = typeof message;
|
||||||
if (message === null || message === undefined) {
|
if (type !== 'string') {
|
||||||
|
if (type === 'object') {
|
||||||
|
if (message === null) {
|
||||||
throw ERROR;
|
throw ERROR;
|
||||||
} else if (message.constructor === root.ArrayBuffer) {
|
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
||||||
message = new Uint8Array(message);
|
message = new Uint8Array(message);
|
||||||
}
|
} else if (!Array.isArray(message)) {
|
||||||
}
|
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
||||||
var length = message.length;
|
|
||||||
if (notString) {
|
|
||||||
if (typeof length !== 'number' ||
|
|
||||||
!Array.isArray(message) &&
|
|
||||||
!(ARRAY_BUFFER && ArrayBuffer.isView(message))) {
|
|
||||||
throw ERROR;
|
throw ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var code, index = 0, i, blocks = this.blocks;
|
} else {
|
||||||
|
throw ERROR;
|
||||||
|
}
|
||||||
|
notString = true;
|
||||||
|
}
|
||||||
|
var code, index = 0, i, length = message.length, blocks = this.blocks;
|
||||||
var buffer8 = this.buffer8;
|
var buffer8 = this.buffer8;
|
||||||
|
|
||||||
while (index < length) {
|
while (index < length) {
|
||||||
@@ -330,6 +338,10 @@
|
|||||||
this.start = i;
|
this.start = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.bytes > 4294967295) {
|
||||||
|
this.hBytes += this.bytes / 4294967296 << 0;
|
||||||
|
this.bytes = this.bytes % 4294967296;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -351,6 +363,7 @@
|
|||||||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
||||||
}
|
}
|
||||||
blocks[14] = this.bytes << 3;
|
blocks[14] = this.bytes << 3;
|
||||||
|
blocks[15] = this.hBytes << 3 | this.bytes >>> 29;
|
||||||
this.hash();
|
this.hash();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -712,7 +725,7 @@
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Dec 18 2017 18:48:59 GMT+0800 (CST)
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script> prettyPrint(); </script>
|
<script> prettyPrint(); </script>
|
||||||
|
|||||||
Generated
+1954
File diff suppressed because it is too large
Load Diff
+12
-7
@@ -1,23 +1,23 @@
|
|||||||
{
|
{
|
||||||
"name": "js-md5",
|
"name": "js-md5",
|
||||||
"version": "0.6.0",
|
"version": "0.7.3",
|
||||||
"description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.",
|
"description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.",
|
||||||
"main": "src/md5.js",
|
"main": "src/md5.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"expect.js": "~0.3.1",
|
"expect.js": "~0.3.1",
|
||||||
"jscoverage": "~0.5.9",
|
|
||||||
"jsdoc": "^3.4.0",
|
"jsdoc": "^3.4.0",
|
||||||
"mocha": "~2.3.4",
|
"mocha": "~2.3.4",
|
||||||
|
"nyc": "^11.3.0",
|
||||||
"requirejs": "^2.1.22",
|
"requirejs": "^2.1.22",
|
||||||
"uglify-js": "~2.4.10",
|
"uglify-js": "^3.1.9",
|
||||||
"webworker-threads": "^0.7.11"
|
"webworker-threads": "^0.7.11"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha tests/node-test.js -r jscoverage",
|
"test": "nyc mocha tests/node-test.js",
|
||||||
"report": "mocha tests/node-test.js -r jscoverage --covout=html",
|
"report": "nyc --reporter=html --reporter=text mocha tests/node-test.js",
|
||||||
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls",
|
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
||||||
"doc": "rm -rf doc;jsdoc src README.md -d doc",
|
"doc": "rm -rf doc;jsdoc src README.md -d doc",
|
||||||
"compress": "uglifyjs src/md5.js --compress --mangle --comments --output build/md5.min.js",
|
"compress": "uglifyjs src/md5.js -c -m eval --comments --output build/md5.min.js",
|
||||||
"build": "npm run-script compress;npm run-script doc"
|
"build": "npm run-script compress;npm run-script doc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -36,5 +36,10 @@
|
|||||||
"homepage": "https://github.com/emn178/js-md5",
|
"homepage": "https://github.com/emn178/js-md5",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/emn178/js-md5/issues"
|
"url": "https://github.com/emn178/js-md5/issues"
|
||||||
|
},
|
||||||
|
"nyc": {
|
||||||
|
"exclude": [
|
||||||
|
"tests"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-14
@@ -2,7 +2,7 @@
|
|||||||
* [js-md5]{@link https://github.com/emn178/js-md5}
|
* [js-md5]{@link https://github.com/emn178/js-md5}
|
||||||
*
|
*
|
||||||
* @namespace md5
|
* @namespace md5
|
||||||
* @version 0.6.0
|
* @version 0.7.3
|
||||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||||
* @copyright Chen, Yi-Cyuan 2014-2017
|
* @copyright Chen, Yi-Cyuan 2014-2017
|
||||||
* @license MIT
|
* @license MIT
|
||||||
@@ -45,6 +45,12 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
||||||
|
ArrayBuffer.isView = function (obj) {
|
||||||
|
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method hex
|
* @method hex
|
||||||
* @memberof md5
|
* @memberof md5
|
||||||
@@ -192,7 +198,7 @@
|
|||||||
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = 0;
|
this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;
|
||||||
this.finalized = this.hashed = false;
|
this.finalized = this.hashed = false;
|
||||||
this.first = true;
|
this.first = true;
|
||||||
}
|
}
|
||||||
@@ -210,23 +216,25 @@
|
|||||||
if (this.finalized) {
|
if (this.finalized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var notString = typeof(message) != 'string';
|
|
||||||
if (notString) {
|
var notString, type = typeof message;
|
||||||
if (message === null || message === undefined) {
|
if (type !== 'string') {
|
||||||
|
if (type === 'object') {
|
||||||
|
if (message === null) {
|
||||||
throw ERROR;
|
throw ERROR;
|
||||||
} else if (message.constructor === root.ArrayBuffer) {
|
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
||||||
message = new Uint8Array(message);
|
message = new Uint8Array(message);
|
||||||
}
|
} else if (!Array.isArray(message)) {
|
||||||
}
|
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
||||||
var length = message.length;
|
|
||||||
if (notString) {
|
|
||||||
if (typeof length !== 'number' ||
|
|
||||||
!Array.isArray(message) &&
|
|
||||||
!(ARRAY_BUFFER && ArrayBuffer.isView(message))) {
|
|
||||||
throw ERROR;
|
throw ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var code, index = 0, i, blocks = this.blocks;
|
} else {
|
||||||
|
throw ERROR;
|
||||||
|
}
|
||||||
|
notString = true;
|
||||||
|
}
|
||||||
|
var code, index = 0, i, length = message.length, blocks = this.blocks;
|
||||||
var buffer8 = this.buffer8;
|
var buffer8 = this.buffer8;
|
||||||
|
|
||||||
while (index < length) {
|
while (index < length) {
|
||||||
@@ -302,6 +310,10 @@
|
|||||||
this.start = i;
|
this.start = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.bytes > 4294967295) {
|
||||||
|
this.hBytes += this.bytes / 4294967296 << 0;
|
||||||
|
this.bytes = this.bytes % 4294967296;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -323,6 +335,7 @@
|
|||||||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
||||||
}
|
}
|
||||||
blocks[14] = this.bytes << 3;
|
blocks[14] = this.bytes << 3;
|
||||||
|
blocks[15] = this.hBytes << 3 | this.bytes >>> 29;
|
||||||
this.hash();
|
this.hash();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+38
-38
@@ -1,56 +1,60 @@
|
|||||||
expect = require('expect.js');
|
expect = require('expect.js');
|
||||||
Worker = require('webworker-threads').Worker;
|
Worker = require('webworker-threads').Worker;
|
||||||
|
|
||||||
|
function unset() {
|
||||||
|
delete require.cache[require.resolve('../src/md5.js')];
|
||||||
|
delete require.cache[require.resolve('./test.js')];
|
||||||
|
md5 = null;
|
||||||
|
BUFFER = undefined;
|
||||||
|
JS_MD5_NO_WINDOW = undefined;
|
||||||
|
JS_MD5_NO_NODE_JS = undefined;
|
||||||
|
JS_MD5_NO_COMMON_JS = undefined;
|
||||||
|
JS_MD5_NO_ARRAY_BUFFER = undefined;
|
||||||
|
JS_MD5_NO_ARRAY_BUFFER_IS_VIEW = undefined;
|
||||||
|
window = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function runCommonJsTest() {
|
||||||
|
md5 = require('../src/md5.js');
|
||||||
|
require('./test.js');
|
||||||
|
unset();
|
||||||
|
}
|
||||||
|
|
||||||
|
function runWindowTest() {
|
||||||
|
window = global;
|
||||||
|
require('../src/md5.js');
|
||||||
|
require('./test.js');
|
||||||
|
unset();
|
||||||
|
}
|
||||||
|
|
||||||
// Node.js env
|
// Node.js env
|
||||||
BUFFER = true;
|
BUFFER = true;
|
||||||
md5 = require('../src/md5.js');
|
runCommonJsTest();
|
||||||
require('./test.js');
|
|
||||||
|
|
||||||
delete require.cache[require.resolve('../src/md5.js')]
|
|
||||||
delete require.cache[require.resolve('./test.js')]
|
|
||||||
md5 = null
|
|
||||||
|
|
||||||
// Webpack browser env
|
// Webpack browser env
|
||||||
JS_MD5_NO_NODE_JS = true;
|
JS_MD5_NO_NODE_JS = true;
|
||||||
BUFFER = false;
|
runCommonJsTest();
|
||||||
window = global;
|
|
||||||
md5 = require('../src/md5.js');
|
|
||||||
require('./test.js');
|
|
||||||
|
|
||||||
delete require.cache[require.resolve('../src/md5.js')];
|
|
||||||
delete require.cache[require.resolve('./test.js')];
|
|
||||||
md5 = null;
|
|
||||||
|
|
||||||
// browser env
|
// browser env
|
||||||
JS_MD5_NO_NODE_JS = true;
|
JS_MD5_NO_NODE_JS = true;
|
||||||
JS_MD5_NO_COMMON_JS = true;
|
JS_MD5_NO_COMMON_JS = true;
|
||||||
BUFFER = false;
|
runWindowTest();
|
||||||
window = global;
|
|
||||||
require('../src/md5.js');
|
|
||||||
require('./test.js');
|
|
||||||
|
|
||||||
delete require.cache[require.resolve('../src/md5.js')];
|
|
||||||
delete require.cache[require.resolve('./test.js')];
|
|
||||||
md5 = null;
|
|
||||||
|
|
||||||
// browser env and no array buffer
|
// browser env and no array buffer
|
||||||
JS_MD5_NO_NODE_JS = true;
|
JS_MD5_NO_NODE_JS = true;
|
||||||
JS_MD5_NO_COMMON_JS = true;
|
JS_MD5_NO_COMMON_JS = true;
|
||||||
JS_MD5_NO_ARRAY_BUFFER = true;
|
JS_MD5_NO_ARRAY_BUFFER = true;
|
||||||
BUFFER = false;
|
runWindowTest();
|
||||||
window = global;
|
|
||||||
require('../src/md5.js');
|
|
||||||
require('./test.js');
|
|
||||||
|
|
||||||
delete require.cache[require.resolve('../src/md5.js')];
|
// browser env and no isView
|
||||||
delete require.cache[require.resolve('./test.js')];
|
JS_MD5_NO_NODE_JS = true;
|
||||||
md5 = null;
|
JS_MD5_NO_COMMON_JS = true;
|
||||||
|
JS_MD5_NO_ARRAY_BUFFER_IS_VIEW = true;
|
||||||
|
runWindowTest();
|
||||||
|
|
||||||
// browser AMD
|
// browser AMD
|
||||||
JS_MD5_NO_NODE_JS = true;
|
JS_MD5_NO_NODE_JS = true;
|
||||||
JS_MD5_NO_COMMON_JS = true;
|
JS_MD5_NO_COMMON_JS = true;
|
||||||
JS_MD5_NO_ARRAY_BUFFER = false;
|
|
||||||
BUFFER = false;
|
|
||||||
window = global;
|
window = global;
|
||||||
define = function (func) {
|
define = function (func) {
|
||||||
md5 = func();
|
md5 = func();
|
||||||
@@ -59,10 +63,7 @@ define = function (func) {
|
|||||||
define.amd = true;
|
define.amd = true;
|
||||||
|
|
||||||
require('../src/md5.js');
|
require('../src/md5.js');
|
||||||
|
unset();
|
||||||
delete require.cache[require.resolve('../src/md5.js')];
|
|
||||||
delete require.cache[require.resolve('./test.js')];
|
|
||||||
md5 = null;
|
|
||||||
|
|
||||||
// webworker
|
// webworker
|
||||||
WORKER = 'tests/worker.js';
|
WORKER = 'tests/worker.js';
|
||||||
@@ -70,12 +71,11 @@ SOURCE = 'src/md5.js';
|
|||||||
|
|
||||||
require('./worker-test.js');
|
require('./worker-test.js');
|
||||||
|
|
||||||
|
delete require.cache[require.resolve('./worker-test.js')];
|
||||||
|
|
||||||
// cover webworker
|
// cover webworker
|
||||||
JS_MD5_NO_WINDOW = true;
|
JS_MD5_NO_WINDOW = true;
|
||||||
JS_MD5_NO_NODE_JS = true;
|
JS_MD5_NO_NODE_JS = true;
|
||||||
JS_MD5_NO_COMMON_JS = false;
|
|
||||||
JS_MD5_NO_ARRAY_BUFFER = false;
|
|
||||||
BUFFER = false;
|
|
||||||
WORKER = './worker.js';
|
WORKER = './worker.js';
|
||||||
SOURCE = '../src/md5.js';
|
SOURCE = '../src/md5.js';
|
||||||
window = global;
|
window = global;
|
||||||
|
|||||||
+7
-1
@@ -241,8 +241,14 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
context('when large size', function () {
|
||||||
|
var hash = md5.create();
|
||||||
|
hash.bytes = 4294967295;
|
||||||
|
hash.update('any');
|
||||||
|
expect(hash.hBytes).to.be(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#bas64', function () {
|
describe('#bas64', function () {
|
||||||
for (var testCaseName in base64TestCases) {
|
for (var testCaseName in base64TestCases) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
(function () {
|
(function (Worker, WORKER, SOURCE) {
|
||||||
var cases = {
|
var cases = {
|
||||||
'd41d8cd98f00b204e9800998ecf8427e': '',
|
'd41d8cd98f00b204e9800998ecf8427e': '',
|
||||||
'9e107d9d372bb6826bd81d3542a419d6': 'The quick brown fox jumps over the lazy dog',
|
'9e107d9d372bb6826bd81d3542a419d6': 'The quick brown fox jumps over the lazy dog',
|
||||||
@@ -18,4 +18,4 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})();
|
})(Worker, WORKER, SOURCE);
|
||||||
|
|||||||
Reference in New Issue
Block a user