mirror of
https://github.com/emn178/js-md5.git
synced 2026-08-13 04:51:44 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24d8eb504d | ||
|
|
a54f102b8a | ||
|
|
e7f1ca7da8 | ||
|
|
b808ed4605 | ||
|
|
2bdc4894fc | ||
|
|
c00df3af37 | ||
|
|
8b9a23ce32 | ||
|
|
da009f933f | ||
|
|
5fcee84417 |
+1
-1
@@ -1,2 +1,2 @@
|
||||
/node_modules/
|
||||
/tests/
|
||||
node_modules/
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
covreporter
|
||||
node_modules
|
||||
/node_modules/
|
||||
/covreporter/
|
||||
|
||||
+2
-5
@@ -1,10 +1,7 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4.1"
|
||||
- "4.0"
|
||||
- "0.12"
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
- "6.11.4"
|
||||
- "8.6.0"
|
||||
before_install:
|
||||
- npm install coveralls
|
||||
- npm install mocha-lcov-reporter
|
||||
|
||||
+71
-31
@@ -1,49 +1,89 @@
|
||||
# v0.4.0 / 2015-12-28
|
||||
# Change Log
|
||||
|
||||
* Added support for update hash.
|
||||
* Added support for bytes array output.
|
||||
* Added support for ArrayBuffer output.
|
||||
* Added support for AMD.
|
||||
## v0.7.0 / 2017-10-29
|
||||
### Fixed
|
||||
- incorrect result when file size >= 512M.
|
||||
|
||||
# v0.3.0 / 2015-03-07
|
||||
## v0.6.1 / 2017-10-07
|
||||
### Fixed
|
||||
- ArrayBuffer.isView issue in IE10.
|
||||
|
||||
* Support byte Array, Uint8Array and ArrayBuffer input.
|
||||
### Improved
|
||||
- performance of input check.
|
||||
|
||||
# v0.2.2 / 2015-02-01
|
||||
## v0.6.0 / 2017-07-28
|
||||
### Added
|
||||
- support base64 string output.
|
||||
|
||||
* Fixed bug when special length.
|
||||
* Improve performance for node.js.
|
||||
## v0.5.0 / 2017-07-14
|
||||
### Added
|
||||
- support for web worker. #11
|
||||
|
||||
# v0.2.1 / 2015-01-13
|
||||
### Changed
|
||||
- throw error if input type is incorrect.
|
||||
- prevent webpack to require dependencies.
|
||||
|
||||
* Improve performance.
|
||||
## v0.4.2 / 2017-01-18
|
||||
### Fixed
|
||||
- `root` is undefined in some special environment. #7
|
||||
|
||||
# v0.2.0 / 2015-01-12
|
||||
## v0.4.1 / 2016-03-31
|
||||
### Removed
|
||||
- length detection in node.js.
|
||||
### Deprecated
|
||||
- `buffer` and replace by `arrayBuffer`.
|
||||
|
||||
* Remove ascii parameter.
|
||||
* Improve performance.
|
||||
## v0.4.0 / 2015-12-28
|
||||
### Added
|
||||
- support for update hash.
|
||||
- support for bytes array output.
|
||||
- support for ArrayBuffer output.
|
||||
- support for AMD.
|
||||
|
||||
# v0.1.4 / 2015-01-11
|
||||
## v0.3.0 / 2015-03-07
|
||||
### Added
|
||||
- support byte Array, Uint8Array and ArrayBuffer input.
|
||||
|
||||
* Improve performance.
|
||||
* Add test case.
|
||||
## v0.2.2 / 2015-02-01
|
||||
### Fixed
|
||||
- bug when special length.
|
||||
### Improve
|
||||
- performance for node.js.
|
||||
|
||||
# v0.1.3 / 2015-01-05
|
||||
## v0.2.1 / 2015-01-13
|
||||
### Improve
|
||||
- performance.
|
||||
|
||||
* Improve performance.
|
||||
* Add bower package.
|
||||
* Fixed JSHint warnings.
|
||||
* Add travis.
|
||||
* Add coveralls.
|
||||
## v0.2.0 / 2015-01-12
|
||||
### Removed
|
||||
- ascii parameter.
|
||||
### Improve
|
||||
- performance.
|
||||
|
||||
# v0.1.2 / 2014-07-27
|
||||
## v0.1.4 / 2015-01-11
|
||||
### Improve
|
||||
- performance.
|
||||
### Added
|
||||
- test cases.
|
||||
|
||||
Fixed accents bug
|
||||
## v0.1.3 / 2015-01-05
|
||||
### Added
|
||||
- bower package.
|
||||
- travis.
|
||||
- coveralls.
|
||||
### Improved
|
||||
- performance.
|
||||
### Fixed
|
||||
- JSHint warnings.
|
||||
|
||||
# v0.1.1 / 2014-01-05
|
||||
## v0.1.2 / 2014-07-27
|
||||
### Fixed
|
||||
- accents bug
|
||||
|
||||
Update license
|
||||
## v0.1.1 / 2014-01-05
|
||||
### Changed
|
||||
- license
|
||||
|
||||
# v0.1.0 / 2014-01-04
|
||||
|
||||
Initial release
|
||||
## v0.1.0 / 2014-01-04
|
||||
### Added
|
||||
- initial release
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Copyright 2014-2015 Yi-Cyuan Chen
|
||||
Copyright 2014-2017 Chen, Yi-Cyuan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
[](https://travis-ci.org/emn178/js-md5)
|
||||
[](https://coveralls.io/r/emn178/js-md5?branch=master)
|
||||
[](https://nodei.co/npm/js-md5/)
|
||||
|
||||
A simple MD5 hash function for JavaScript supports UTF-8 encoding.
|
||||
|
||||
## Demo
|
||||
@@ -21,6 +22,9 @@ For node.js, you can use this command to install:
|
||||
|
||||
npm install js-md5
|
||||
|
||||
## Notice
|
||||
`buffer` method is deprecated. This maybe confuse with Buffer in node.js. Please use `arrayBuffer` instead.
|
||||
|
||||
## Usage
|
||||
You could use like this:
|
||||
```JavaScript
|
||||
@@ -59,16 +63,14 @@ md5(''); // d41d8cd98f00b204e9800998ecf8427e
|
||||
md5.hex(''); // d41d8cd98f00b204e9800998ecf8427e
|
||||
md5.array(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]
|
||||
md5.digest(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]
|
||||
md5.buffer(''); // ArrayBuffer
|
||||
md5.arrayBuffer(''); // ArrayBuffer
|
||||
md5.buffer(''); // ArrayBuffer, deprecated, This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
|
||||
md5.base64(''); // 1B2M2Y8AsgTpgAmY7PhCfg==
|
||||
```
|
||||
|
||||
## Benchmark
|
||||
[UTF8](http://jsperf.com/md5-shootout/81)
|
||||
[ASCII](http://jsperf.com/md5-shootout/82)
|
||||
|
||||
## License
|
||||
The project is released under the [MIT license](http://www.opensource.org/licenses/MIT).
|
||||
|
||||
## Contact
|
||||
The project's website is located at https://github.com/emn178/js-md5
|
||||
Author: Yi-Cyuan Chen (emn178@gmail.com)
|
||||
Author: Chen, Yi-Cyuan (emn178@gmail.com)
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"name": "js-md5",
|
||||
"version": "0.4.0",
|
||||
"version": "0.7.0",
|
||||
"main": ["src/md5.js"],
|
||||
"ignore": [
|
||||
"samples",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+4
-4
File diff suppressed because one or more lines are too long
+282
-10
@@ -28,7 +28,7 @@
|
||||
|
||||
<header>
|
||||
|
||||
<h2>Md5</h2>
|
||||
<h2><span class="attribs"><span class="type-signature"></span></span>Md5<span class="signature">()</span><span class="type-signature"></span></h2>
|
||||
|
||||
|
||||
</header>
|
||||
@@ -40,12 +40,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="Md5"><span class="type-signature"></span>new Md5<span class="signature">()</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
This is internal class.
|
||||
</div>
|
||||
@@ -91,7 +93,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line168">line 168</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line178">line 178</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -125,6 +127,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -140,6 +144,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
@@ -147,12 +153,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="array"><span class="type-signature"></span>array<span class="signature">()</span><span class="type-signature"> → {Array}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as bytes array
|
||||
</div>
|
||||
@@ -198,7 +206,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line550">line 550</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line575">line 575</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -252,6 +260,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>hash.array();</code></pre>
|
||||
@@ -263,7 +273,9 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="buffer"><span class="type-signature"></span>buffer<span class="signature">()</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
|
||||
|
||||
<h4 class="name" id="arrayBuffer"><span class="type-signature"></span>arrayBuffer<span class="signature">()</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -314,7 +326,249 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line562">line 562</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line587">line 587</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-see">See:</dt>
|
||||
<dd class="tag-see">
|
||||
<ul>
|
||||
<li><a href="md5.html#.arrayBuffer">md5.arrayBuffer</a></li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
ArrayBuffer
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">ArrayBuffer</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>hash.arrayBuffer();</code></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="base64"><span class="type-signature"></span>base64<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as base64 string
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line622">line 622</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-see">See:</dt>
|
||||
<dd class="tag-see">
|
||||
<ul>
|
||||
<li><a href="md5.html#.base64">md5.base64</a></li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
base64 string
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">String</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>hash.base64();</code></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="buffer"><span class="type-signature"></span>buffer<span class="signature">()</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as ArrayBuffer
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line609">line 609</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -368,6 +622,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>hash.buffer();</code></pre>
|
||||
@@ -379,12 +635,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="digest"><span class="type-signature"></span>digest<span class="signature">()</span><span class="type-signature"> → {Array}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as bytes array
|
||||
</div>
|
||||
@@ -430,7 +688,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line528">line 528</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line553">line 553</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -484,6 +742,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>hash.digest();</code></pre>
|
||||
@@ -495,12 +755,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="hex"><span class="type-signature"></span>hex<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as hex string
|
||||
</div>
|
||||
@@ -546,7 +808,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line483">line 483</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line508">line 508</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -600,6 +862,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>hash.hex();</code></pre>
|
||||
@@ -611,12 +875,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="toString"><span class="type-signature"></span>toString<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as hex string
|
||||
</div>
|
||||
@@ -662,7 +928,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line516">line 516</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line541">line 541</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -716,6 +982,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>hash.toString();</code></pre>
|
||||
@@ -727,12 +995,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">(message)</span><span class="type-signature"> → {<a href="Md5_.html">Md5</a>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Update hash
|
||||
</div>
|
||||
@@ -836,7 +1106,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line196">line 196</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line206">line 206</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -897,6 +1167,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
@@ -913,7 +1185,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Dec 28 2015 15:48:48 GMT+0800 (CST)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Oct 29 2017 20:15:53 GMT+0800 (CST)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
+8
-2
@@ -94,6 +94,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
@@ -101,12 +103,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="md5%08"><span class="type-signature"></span>md5<span class="signature">(message)</span><span class="type-signature"> → {String}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Md5 hash function, export to global in browsers.
|
||||
</div>
|
||||
@@ -210,7 +214,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line589">line 589</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line655">line 655</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -257,6 +261,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>md5(''); // d41d8cd98f00b204e9800998ecf8427e
|
||||
@@ -294,7 +300,7 @@ md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Dec 28 2015 15:48:48 GMT+0800 (CST)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Oct 29 2017 20:15:53 GMT+0800 (CST)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
+10
-7
@@ -44,12 +44,14 @@
|
||||
|
||||
<section>
|
||||
<article><h1>js-md5</h1><p><a href="https://travis-ci.org/emn178/js-md5"><img src="https://travis-ci.org/emn178/js-md5.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://coveralls.io/r/emn178/js-md5?branch=master"><img src="https://coveralls.io/repos/emn178/js-md5/badge.svg?branch=master" alt="Coverage Status"></a><br><a href="https://nodei.co/npm/js-md5/"><img src="https://nodei.co/npm/js-md5.png?stars&downloads" alt="NPM"></a><br>A simple MD5 hash function for JavaScript supports UTF-8 encoding.</p>
|
||||
<h2>Demo</h2><p><a href="http://emn178.github.io/online-tools/md5.html">MD5 Online</a><br><a href="http://emn178.github.io/online-tools/md5_checksum.html">MD5 File Checksum Online</a> </p>
|
||||
<a href="https://coveralls.io/r/emn178/js-md5?branch=master"><img src="https://coveralls.io/repos/emn178/js-md5/badge.svg?branch=master" alt="Coverage Status"></a><br><a href="https://nodei.co/npm/js-md5/"><img src="https://nodei.co/npm/js-md5.png?stars&downloads" alt="NPM"></a></p>
|
||||
<p>A simple MD5 hash function for JavaScript supports UTF-8 encoding.</p>
|
||||
<h2>Demo</h2><p><a href="http://emn178.github.io/online-tools/md5.html">MD5 Online</a><br><a href="http://emn178.github.io/online-tools/md5_checksum.html">MD5 File Checksum Online</a></p>
|
||||
<h2>Download</h2><p><a href="https://raw.github.com/emn178/js-md5/master/build/md5.min.js">Compress</a><br><a href="https://raw.github.com/emn178/js-md5/master/src/md5.js">Uncompress</a></p>
|
||||
<h2>Installation</h2><p>You can also install js-md5 by using Bower.</p>
|
||||
<pre class="prettyprint source"><code>bower install md5</code></pre><p>For node.js, you can use this command to install:</p>
|
||||
<pre class="prettyprint source"><code>npm install js-md5</code></pre><h2>Usage</h2><p>You could use like this:</p>
|
||||
<pre class="prettyprint source"><code>npm install js-md5</code></pre><h2>Notice</h2><p><code>buffer</code> method is deprecated. This maybe confuse with Buffer in node.js. Please use <code>arrayBuffer</code> instead.</p>
|
||||
<h2>Usage</h2><p>You could use like this:</p>
|
||||
<pre class="prettyprint source lang-JavaScript"><code>md5('Message to hash');
|
||||
var hash = md5.create();
|
||||
hash.update('Message to hash');
|
||||
@@ -74,9 +76,10 @@ md5(''); // d41d8cd98f00b204e9800998ecf8427e
|
||||
md5.hex(''); // d41d8cd98f00b204e9800998ecf8427e
|
||||
md5.array(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]
|
||||
md5.digest(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]
|
||||
md5.buffer(''); // ArrayBuffer</code></pre><h2>Benchmark</h2><p><a href="http://jsperf.com/md5-shootout/81">UTF8</a><br><a href="http://jsperf.com/md5-shootout/82">ASCII</a></p>
|
||||
<h2>License</h2><p>The project is released under the <a href="http://www.opensource.org/licenses/MIT">MIT license</a>.</p>
|
||||
<h2>Contact</h2><p>The project's website is located at https://github.com/emn178/js-md5<br>Author: Yi-Cyuan Chen (emn178@gmail.com)</p></article>
|
||||
md5.arrayBuffer(''); // ArrayBuffer
|
||||
md5.buffer(''); // ArrayBuffer, deprecated, This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
|
||||
md5.base64(''); // 1B2M2Y8AsgTpgAmY7PhCfg==</code></pre><h2>License</h2><p>The project is released under the <a href="http://www.opensource.org/licenses/MIT">MIT license</a>.</p>
|
||||
<h2>Contact</h2><p>The project's website is located at https://github.com/emn178/js-md5<br>Author: Chen, Yi-Cyuan (emn178@gmail.com)</p></article>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -93,7 +96,7 @@ md5.buffer(''); // ArrayBuffer</code></pre><h2>Benchmark</h2><p><a href="http://
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Dec 28 2015 15:48:48 GMT+0800 (CST)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Oct 29 2017 20:15:53 GMT+0800 (CST)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
+379
-244
@@ -47,7 +47,7 @@
|
||||
|
||||
|
||||
<dt class="tag-version">Version:</dt>
|
||||
<dd class="tag-version"><ul class="dummy"><li>0.4.0</li></ul></dd>
|
||||
<dd class="tag-version"><ul class="dummy"><li>0.7.0</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
@@ -68,14 +68,14 @@
|
||||
<dt class="tag-author">Author:</dt>
|
||||
<dd class="tag-author">
|
||||
<ul>
|
||||
<li>Yi-Cyuan Chen [emn178@gmail.com]</li>
|
||||
<li>Chen, Yi-Cyuan [emn178@gmail.com]</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt class="tag-copyright">Copyright:</dt>
|
||||
<dd class="tag-copyright"><ul class="dummy"><li>Yi-Cyuan Chen 2014-2015</li></ul></dd>
|
||||
<dd class="tag-copyright"><ul class="dummy"><li>Chen, Yi-Cyuan 2014-2017</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
@@ -115,239 +115,6 @@
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Members</h3>
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".asciiThreshold"><span class="type-signature">(static) </span>asciiThreshold<span class="type-signature"> :Number</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
To use node.js md5 if ascii string length is greater than this value.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<h5>Type:</h5>
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
<span class="param-type">Number</span>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-default">Default Value:</dt>
|
||||
<dd class="tag-default"><ul class="dummy">
|
||||
<li>60</li>
|
||||
</ul></dd>
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line150">line 150</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".bytesThreshold"><span class="type-signature">(static) </span>bytesThreshold<span class="type-signature"> :Number</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
To use node.js md5 if bytes length is greater than this value.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<h5>Type:</h5>
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
<span class="param-type">Number</span>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-default">Default Value:</dt>
|
||||
<dd class="tag-default"><ul class="dummy">
|
||||
<li>245</li>
|
||||
</ul></dd>
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line158">line 158</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".utf8Threshold"><span class="type-signature">(static) </span>utf8Threshold<span class="type-signature"> :Number</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
To use node.js md5 if UTF-8 string length is greater than this value.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<h5>Type:</h5>
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
<span class="param-type">Number</span>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-default">Default Value:</dt>
|
||||
<dd class="tag-default"><ul class="dummy">
|
||||
<li>18</li>
|
||||
</ul></dd>
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line142">line 142</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -359,12 +126,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".array"><span class="type-signature">(static) </span>array<span class="signature">(message)</span><span class="type-signature"> → {Array}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as bytes array
|
||||
</div>
|
||||
@@ -468,7 +237,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line52">line 52</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line74">line 74</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -515,6 +284,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>md5.array('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
@@ -526,7 +297,9 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".buffer"><span class="type-signature">(static) </span>buffer<span class="signature">(message)</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
|
||||
|
||||
<h4 class="name" id=".arrayBuffer"><span class="type-signature">(static) </span>arrayBuffer<span class="signature">(message)</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -635,7 +408,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line61">line 61</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line83">line 83</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -682,6 +455,352 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>md5.arrayBuffer('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".base64"><span class="type-signature">(static) </span>base64<span class="signature">(message)</span><span class="type-signature"> → {String}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as base64 string
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>message</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">String</span>
|
||||
|
|
||||
|
||||
<span class="param-type">Array</span>
|
||||
|
|
||||
|
||||
<span class="param-type">Uint8Array</span>
|
||||
|
|
||||
|
||||
<span class="param-type">ArrayBuffer</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">message to hash</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line102">line 102</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
base64 string
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">String</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>md5.base64('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".buffer"><span class="type-signature">(static) </span>buffer<span class="signature">(message)</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as ArrayBuffer
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>message</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">String</span>
|
||||
|
|
||||
|
||||
<span class="param-type">Array</span>
|
||||
|
|
||||
|
||||
<span class="param-type">Uint8Array</span>
|
||||
|
|
||||
|
||||
<span class="param-type">ArrayBuffer</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">message to hash</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line92">line 92</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
ArrayBuffer
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">ArrayBuffer</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>md5.buffer('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
@@ -693,12 +812,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".create"><span class="type-signature">(static) </span>create<span class="signature">()</span><span class="type-signature"> → {<a href="Md5_.html">Md5</a>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Create Md5 object
|
||||
</div>
|
||||
@@ -744,7 +865,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line76">line 76</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line117">line 117</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -791,6 +912,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>var hash = md5.create();</code></pre>
|
||||
@@ -802,12 +925,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".digest"><span class="type-signature">(static) </span>digest<span class="signature">(message)</span><span class="type-signature"> → {Array}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as bytes array
|
||||
</div>
|
||||
@@ -911,7 +1036,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line43">line 43</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line65">line 65</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -958,6 +1083,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>md5.digest('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
@@ -969,12 +1096,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".hex"><span class="type-signature">(static) </span>hex<span class="signature">(message)</span><span class="type-signature"> → {String}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Output hash as hex string
|
||||
</div>
|
||||
@@ -1078,7 +1207,7 @@
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line32">line 32</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line54">line 54</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1125,6 +1254,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>md5.hex('The quick brown fox jumps over the lazy dog');
|
||||
@@ -1138,12 +1269,14 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".update"><span class="type-signature">(static) </span>update<span class="signature">(message)</span><span class="type-signature"> → {<a href="Md5_.html">Md5</a>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Create and update Md5 object
|
||||
</div>
|
||||
@@ -1247,7 +1380,7 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line84">line 84</a>
|
||||
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line125">line 125</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
@@ -1294,6 +1427,8 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Example</h5>
|
||||
|
||||
<pre class="prettyprint"><code>var hash = md5.update('The quick brown fox jumps over the lazy dog');
|
||||
@@ -1325,7 +1460,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Dec 28 2015 15:48:48 GMT+0800 (CST)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Oct 29 2017 20:15:53 GMT+0800 (CST)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
+139
-73
@@ -30,25 +30,35 @@
|
||||
* [js-md5]{@link https://github.com/emn178/js-md5}
|
||||
*
|
||||
* @namespace md5
|
||||
* @version 0.4.0
|
||||
* @author Yi-Cyuan Chen [emn178@gmail.com]
|
||||
* @copyright Yi-Cyuan Chen 2014-2015
|
||||
* @version 0.7.0
|
||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||
* @copyright Chen, Yi-Cyuan 2014-2017
|
||||
* @license MIT
|
||||
*/
|
||||
(function (root) {
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
|
||||
var ERROR = 'input is invalid type';
|
||||
var WINDOW = typeof window === 'object';
|
||||
var root = WINDOW ? window : {};
|
||||
if (root.JS_MD5_NO_WINDOW) {
|
||||
WINDOW = false;
|
||||
}
|
||||
var WEB_WORKER = !WINDOW && typeof self === 'object';
|
||||
var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
|
||||
if (NODE_JS) {
|
||||
root = global;
|
||||
} else if (WEB_WORKER) {
|
||||
root = self;
|
||||
}
|
||||
var COMMON_JS = !root.JS_MD5_TEST && typeof module == 'object' && module.exports;
|
||||
var AMD = typeof define == 'function' && define.amd;
|
||||
var ARRAY_BUFFER = !root.JS_MD5_TEST && typeof ArrayBuffer != 'undefined';
|
||||
var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && typeof module === 'object' && module.exports;
|
||||
var AMD = typeof define === 'function' && define.amd;
|
||||
var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
|
||||
var HEX_CHARS = '0123456789abcdef'.split('');
|
||||
var EXTRA = [128, 32768, 8388608, -2147483648];
|
||||
var SHIFT = [0, 8, 16, 24];
|
||||
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer'];
|
||||
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64'];
|
||||
var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
||||
|
||||
var blocks = [], buffer8;
|
||||
if (ARRAY_BUFFER) {
|
||||
@@ -57,6 +67,18 @@
|
||||
blocks = new Uint32Array(buffer);
|
||||
}
|
||||
|
||||
if (root.JS_MD5_NO_NODE_JS || !Array.isArray) {
|
||||
Array.isArray = function (obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object Array]';
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
* @memberof md5
|
||||
@@ -86,8 +108,18 @@
|
||||
* @example
|
||||
* md5.array('The quick brown fox jumps over the lazy dog');
|
||||
*/
|
||||
/**
|
||||
* @method arrayBuffer
|
||||
* @memberof md5
|
||||
* @description Output hash as ArrayBuffer
|
||||
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
||||
* @returns {ArrayBuffer} ArrayBuffer
|
||||
* @example
|
||||
* md5.arrayBuffer('The quick brown fox jumps over the lazy dog');
|
||||
*/
|
||||
/**
|
||||
* @method buffer
|
||||
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
|
||||
* @memberof md5
|
||||
* @description Output hash as ArrayBuffer
|
||||
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
||||
@@ -95,10 +127,19 @@
|
||||
* @example
|
||||
* md5.buffer('The quick brown fox jumps over the lazy dog');
|
||||
*/
|
||||
/**
|
||||
* @method base64
|
||||
* @memberof md5
|
||||
* @description Output hash as base64 string
|
||||
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
||||
* @returns {String} base64 string
|
||||
* @example
|
||||
* md5.base64('The quick brown fox jumps over the lazy dog');
|
||||
*/
|
||||
var createOutputMethod = function (outputType) {
|
||||
return function(message) {
|
||||
return function (message) {
|
||||
return new Md5(true).update(message)[outputType]();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -132,7 +173,7 @@
|
||||
method.update = function (message) {
|
||||
return method.create().update(message);
|
||||
};
|
||||
for (var i = 0;i < OUTPUT_TYPES.length;++i) {
|
||||
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
||||
var type = OUTPUT_TYPES[i];
|
||||
method[type] = createOutputMethod(type);
|
||||
}
|
||||
@@ -140,58 +181,27 @@
|
||||
};
|
||||
|
||||
var nodeWrap = function (method) {
|
||||
var crypto, Buffer;
|
||||
try {
|
||||
if (root.JS_MD5_TEST) {
|
||||
throw 'JS_MD5_TEST';
|
||||
}
|
||||
crypto = require('crypto');
|
||||
Buffer = require('buffer').Buffer;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return method;
|
||||
}
|
||||
var crypto = eval("require('crypto')");
|
||||
var Buffer = eval("require('buffer').Buffer");
|
||||
var nodeMethod = function (message) {
|
||||
if (typeof message == 'string') {
|
||||
if (message.length <= nodeMethod.utf8Threshold) {
|
||||
return method(message);
|
||||
} else if (message.length <= nodeMethod.asciiThreshold && !/[^\x00-\x7F]/.test(message)) {
|
||||
return method(message);
|
||||
}
|
||||
if (typeof message === 'string') {
|
||||
return crypto.createHash('md5').update(message, 'utf8').digest('hex');
|
||||
} else if (message.constructor == ArrayBuffer) {
|
||||
} else {
|
||||
if (message === null || message === undefined) {
|
||||
throw ERROR;
|
||||
} else if (message.constructor === ArrayBuffer) {
|
||||
message = new Uint8Array(message);
|
||||
} else if (message.length === undefined || message.length <= nodeMethod.bytesThreshold) {
|
||||
}
|
||||
}
|
||||
if (Array.isArray(message) || ArrayBuffer.isView(message) ||
|
||||
message.constructor === Buffer) {
|
||||
return crypto.createHash('md5').update(new Buffer(message)).digest('hex');
|
||||
} else {
|
||||
return method(message);
|
||||
}
|
||||
return crypto.createHash('md5').update(new Buffer(message)).digest('hex');
|
||||
};
|
||||
|
||||
/**
|
||||
* @member {Number} utf8Threshold
|
||||
* @default 18
|
||||
* @description To use node.js md5 if UTF-8 string length is greater than this value.
|
||||
* @memberof md5
|
||||
*/
|
||||
nodeMethod.utf8Threshold = 18;
|
||||
|
||||
/**
|
||||
* @member {Number} asciiThreshold
|
||||
* @default 60
|
||||
* @description To use node.js md5 if ascii string length is greater than this value.
|
||||
* @memberof md5
|
||||
*/
|
||||
nodeMethod.asciiThreshold = 60;
|
||||
|
||||
/**
|
||||
* @member {Number} bytesThreshold
|
||||
* @default 245
|
||||
* @description To use node.js md5 if bytes length is greater than this value.
|
||||
* @memberof md5
|
||||
*/
|
||||
nodeMethod.bytesThreshold = 245;
|
||||
return nodeMethod;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Md5 class
|
||||
@@ -234,11 +244,25 @@
|
||||
if (this.finalized) {
|
||||
return;
|
||||
}
|
||||
var notString = typeof(message) != 'string';
|
||||
if(notString && message.constructor == root.ArrayBuffer) {
|
||||
|
||||
var notString, type = typeof message;
|
||||
if (type !== 'string') {
|
||||
if (type === 'object') {
|
||||
if (message === null) {
|
||||
throw ERROR;
|
||||
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
||||
message = new Uint8Array(message);
|
||||
} else if (!Array.isArray(message)) {
|
||||
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
||||
throw ERROR;
|
||||
}
|
||||
var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
|
||||
}
|
||||
} else {
|
||||
throw ERROR;
|
||||
}
|
||||
notString = true;
|
||||
}
|
||||
var code, index = 0, i, length = message.length, blocks = this.blocks;
|
||||
var buffer8 = this.buffer8;
|
||||
|
||||
while (index < length) {
|
||||
@@ -253,17 +277,17 @@
|
||||
|
||||
if (notString) {
|
||||
if (ARRAY_BUFFER) {
|
||||
for (i = this.start;index < length && i < 64; ++index) {
|
||||
for (i = this.start; index < length && i < 64; ++index) {
|
||||
buffer8[i++] = message[index];
|
||||
}
|
||||
} else {
|
||||
for (i = this.start;index < length && i < 64; ++index) {
|
||||
for (i = this.start; index < length && i < 64; ++index) {
|
||||
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ARRAY_BUFFER) {
|
||||
for (i = this.start;index < length && i < 64; ++index) {
|
||||
for (i = this.start; index < length && i < 64; ++index) {
|
||||
code = message.charCodeAt(index);
|
||||
if (code < 0x80) {
|
||||
buffer8[i++] = code;
|
||||
@@ -283,7 +307,7 @@
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = this.start;index < length && i < 64; ++index) {
|
||||
for (i = this.start; index < length && i < 64; ++index) {
|
||||
code = message.charCodeAt(index);
|
||||
if (code < 0x80) {
|
||||
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
||||
@@ -335,13 +359,14 @@
|
||||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
||||
}
|
||||
blocks[14] = this.bytes << 3;
|
||||
blocks[15] = this.bytes >> 29;
|
||||
this.hash();
|
||||
};
|
||||
|
||||
Md5.prototype.hash = function () {
|
||||
var a, b, c, d, bc, da, blocks = this.blocks;
|
||||
|
||||
if(this.first) {
|
||||
if (this.first) {
|
||||
a = blocks[0] - 680876937;
|
||||
a = (a << 7 | a >>> 25) - 271733879 << 0;
|
||||
d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;
|
||||
@@ -494,7 +519,7 @@
|
||||
b += (d ^ (c | ~a)) + blocks[9] - 343485551;
|
||||
b = (b << 21 | b >>> 11) + c << 0;
|
||||
|
||||
if(this.first) {
|
||||
if (this.first) {
|
||||
this.h0 = a + 1732584193 << 0;
|
||||
this.h1 = b - 271733879 << 0;
|
||||
this.h2 = c - 1732584194 << 0;
|
||||
@@ -563,7 +588,7 @@
|
||||
* @example
|
||||
* hash.digest();
|
||||
*/
|
||||
Md5.prototype.digest = function() {
|
||||
Md5.prototype.digest = function () {
|
||||
this.finalize();
|
||||
|
||||
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
|
||||
@@ -588,16 +613,16 @@
|
||||
Md5.prototype.array = Md5.prototype.digest;
|
||||
|
||||
/**
|
||||
* @method buffer
|
||||
* @method arrayBuffer
|
||||
* @memberof Md5
|
||||
* @instance
|
||||
* @description Output hash as ArrayBuffer
|
||||
* @returns {ArrayBuffer} ArrayBuffer
|
||||
* @see {@link md5.buffer}
|
||||
* @see {@link md5.arrayBuffer}
|
||||
* @example
|
||||
* hash.buffer();
|
||||
* hash.arrayBuffer();
|
||||
*/
|
||||
Md5.prototype.buffer = function() {
|
||||
Md5.prototype.arrayBuffer = function () {
|
||||
this.finalize();
|
||||
|
||||
var buffer = new ArrayBuffer(16);
|
||||
@@ -609,6 +634,47 @@
|
||||
return buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* @method buffer
|
||||
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
|
||||
* @memberof Md5
|
||||
* @instance
|
||||
* @description Output hash as ArrayBuffer
|
||||
* @returns {ArrayBuffer} ArrayBuffer
|
||||
* @see {@link md5.buffer}
|
||||
* @example
|
||||
* hash.buffer();
|
||||
*/
|
||||
Md5.prototype.buffer = Md5.prototype.arrayBuffer;
|
||||
|
||||
/**
|
||||
* @method base64
|
||||
* @memberof Md5
|
||||
* @instance
|
||||
* @description Output hash as base64 string
|
||||
* @returns {String} base64 string
|
||||
* @see {@link md5.base64}
|
||||
* @example
|
||||
* hash.base64();
|
||||
*/
|
||||
Md5.prototype.base64 = function () {
|
||||
var v1, v2, v3, base64Str = '', bytes = this.array();
|
||||
for (var i = 0; i < 15;) {
|
||||
v1 = bytes[i++];
|
||||
v2 = bytes[i++];
|
||||
v3 = bytes[i++];
|
||||
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
|
||||
BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] +
|
||||
BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] +
|
||||
BASE64_ENCODE_CHAR[v3 & 63];
|
||||
}
|
||||
v1 = bytes[i];
|
||||
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
|
||||
BASE64_ENCODE_CHAR[(v1 << 4) & 63] +
|
||||
'==';
|
||||
return base64Str;
|
||||
};
|
||||
|
||||
var exports = createMethod();
|
||||
|
||||
if (COMMON_JS) {
|
||||
@@ -638,7 +704,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
}(this));
|
||||
})();
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
@@ -655,7 +721,7 @@
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Dec 28 2015 15:48:47 GMT+0800 (CST)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Oct 29 2017 20:15:53 GMT+0800 (CST)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
@@ -78,6 +78,10 @@ article dl {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
article img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
section
|
||||
{
|
||||
display: block;
|
||||
@@ -153,7 +157,7 @@ h1
|
||||
margin: 12px 24px 20px;
|
||||
}
|
||||
|
||||
h2, h3
|
||||
h2, h3.subsection-title
|
||||
{
|
||||
font-size: 30px;
|
||||
font-weight: 700;
|
||||
@@ -161,6 +165,13 @@ h2, h3
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
h3
|
||||
{
|
||||
font-size: 24px;
|
||||
letter-spacing: -0.5px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
h4
|
||||
{
|
||||
font-size: 18px;
|
||||
@@ -185,8 +196,34 @@ h6
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.ancestors { color: #999; }
|
||||
.ancestors a
|
||||
table
|
||||
{
|
||||
border-spacing: 0;
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td, th
|
||||
{
|
||||
border: 1px solid #ddd;
|
||||
margin: 0px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
padding: 4px 6px;
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
thead tr
|
||||
{
|
||||
background-color: #ddd;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
th { border-right: 1px solid #aaa; }
|
||||
tr > th:last-child { border-right: 1px solid #ddd; }
|
||||
|
||||
.ancestors, .attribs { color: #999; }
|
||||
.ancestors a, .attribs a
|
||||
{
|
||||
color: #999 !important;
|
||||
text-decoration: none;
|
||||
@@ -296,44 +333,12 @@ h6
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
.params, .props
|
||||
{
|
||||
border-spacing: 0;
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.params .name, .props .name, .name code {
|
||||
color: #4D4E53;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.params td, .params th, .props td, .props th
|
||||
{
|
||||
border: 1px solid #ddd;
|
||||
margin: 0px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
padding: 4px 6px;
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
.params thead tr, .props thead tr
|
||||
{
|
||||
background-color: #ddd;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.params .params thead tr, .props .props thead tr
|
||||
{
|
||||
background-color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.params th, .props th { border-right: 1px solid #aaa; }
|
||||
.params thead .last, .props thead .last { border-right: 1px solid #ddd; }
|
||||
|
||||
.params td.description > p:first-child,
|
||||
.props td.description > p:first-child
|
||||
{
|
||||
|
||||
Generated
+500
@@ -0,0 +1,500 @@
|
||||
{
|
||||
"name": "js-md5",
|
||||
"version": "0.6.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"amdefine": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
|
||||
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
|
||||
"dev": true
|
||||
},
|
||||
"async": {
|
||||
"version": "0.2.10",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
|
||||
"integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=",
|
||||
"dev": true
|
||||
},
|
||||
"babylon": {
|
||||
"version": "7.0.0-beta.19",
|
||||
"resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.19.tgz",
|
||||
"integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==",
|
||||
"dev": true
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz",
|
||||
"integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==",
|
||||
"dev": true
|
||||
},
|
||||
"bluebird": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
|
||||
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==",
|
||||
"dev": true
|
||||
},
|
||||
"camelcase": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
|
||||
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
|
||||
"dev": true
|
||||
},
|
||||
"catharsis": {
|
||||
"version": "0.8.9",
|
||||
"resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.9.tgz",
|
||||
"integrity": "sha1-mMyJDKZS3S7w5ws3klMQ/56Q/Is=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"underscore-contrib": "0.3.0"
|
||||
}
|
||||
},
|
||||
"coffee-script": {
|
||||
"version": "1.12.7",
|
||||
"resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.12.7.tgz",
|
||||
"integrity": "sha512-fLeEhqwymYat/MpTPUjSKHVYYl0ec2mOyALEMLmzr5i1isuG+6jfI2j2d5oBO3VIzgUXgBVIcOT9uH1TFxBckw==",
|
||||
"dev": true
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz",
|
||||
"integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-1.0.3.tgz",
|
||||
"integrity": "sha1-/IxrLWACgEtAgcAgjg9kYLofo+Q=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "0.6.2"
|
||||
}
|
||||
},
|
||||
"decamelize": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
|
||||
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
|
||||
"dev": true
|
||||
},
|
||||
"diff": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz",
|
||||
"integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=",
|
||||
"dev": true
|
||||
},
|
||||
"ejs": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ejs/-/ejs-1.0.0.tgz",
|
||||
"integrity": "sha1-ycYKSKRu5FL7MqccMXuV5aofyz0=",
|
||||
"dev": true
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
||||
"dev": true
|
||||
},
|
||||
"expect.js": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/expect.js/-/expect.js-0.3.1.tgz",
|
||||
"integrity": "sha1-sKWaDS7/VDdUTr8M6qYBWEHQm1s=",
|
||||
"dev": true
|
||||
},
|
||||
"glob": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-3.2.3.tgz",
|
||||
"integrity": "sha1-4xPusknHr/qlxHUoaw4RW1mDlGc=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "2.0.3",
|
||||
"inherits": "2.0.3",
|
||||
"minimatch": "0.2.14"
|
||||
},
|
||||
"dependencies": {
|
||||
"graceful-fs": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz",
|
||||
"integrity": "sha1-fNLNsiiko/Nule+mzBQt59GhNtA=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.1.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
|
||||
"dev": true
|
||||
},
|
||||
"growl": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/growl/-/growl-1.8.1.tgz",
|
||||
"integrity": "sha1-Sy3sjZB+k9szZiTc7AGDUC+MlCg=",
|
||||
"dev": true
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||
"dev": true
|
||||
},
|
||||
"jade": {
|
||||
"version": "0.26.3",
|
||||
"resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz",
|
||||
"integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "0.6.1",
|
||||
"mkdirp": "0.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz",
|
||||
"integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz",
|
||||
"integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"js2xmlparser": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-3.0.0.tgz",
|
||||
"integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"xmlcreate": "1.0.2"
|
||||
}
|
||||
},
|
||||
"jscoverage": {
|
||||
"version": "0.5.9",
|
||||
"resolved": "https://registry.npmjs.org/jscoverage/-/jscoverage-0.5.9.tgz",
|
||||
"integrity": "sha1-M3tR3ZBU6OyTwLCxU3VTtSvwst8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"coffee-script": "1.12.7",
|
||||
"debug": "1.0.3",
|
||||
"ejs": "1.0.0",
|
||||
"optimist": "0.3.1",
|
||||
"uglify-js": "2.4.15",
|
||||
"xfs": "0.1.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"uglify-js": {
|
||||
"version": "2.4.15",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.4.15.tgz",
|
||||
"integrity": "sha1-ErxthDRfvDBuE/cHXWQ3qL9k1+M=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"async": "0.2.10",
|
||||
"optimist": "0.3.7",
|
||||
"source-map": "0.1.34",
|
||||
"uglify-to-browserify": "1.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"optimist": {
|
||||
"version": "0.3.7",
|
||||
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz",
|
||||
"integrity": "sha1-yQlBrVnkJzMokjB00s8ufLxuwNk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wordwrap": "0.0.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"jsdoc": {
|
||||
"version": "3.5.5",
|
||||
"resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz",
|
||||
"integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babylon": "7.0.0-beta.19",
|
||||
"bluebird": "3.5.1",
|
||||
"catharsis": "0.8.9",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"js2xmlparser": "3.0.0",
|
||||
"klaw": "2.0.0",
|
||||
"marked": "0.3.6",
|
||||
"mkdirp": "0.5.1",
|
||||
"requizzle": "0.2.1",
|
||||
"strip-json-comments": "2.0.1",
|
||||
"taffydb": "2.6.2",
|
||||
"underscore": "1.8.3"
|
||||
}
|
||||
},
|
||||
"klaw": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz",
|
||||
"integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "4.1.11"
|
||||
}
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "2.7.3",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz",
|
||||
"integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=",
|
||||
"dev": true
|
||||
},
|
||||
"marked": {
|
||||
"version": "0.3.6",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz",
|
||||
"integrity": "sha1-ssbGGPzOzk74bE/Gy4p8v1rtqNc=",
|
||||
"dev": true
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "0.2.14",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz",
|
||||
"integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lru-cache": "2.7.3",
|
||||
"sigmund": "1.0.1"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"mocha": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-2.3.4.tgz",
|
||||
"integrity": "sha1-himm+wRPLSJapLgaKuLQAWmesmY=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "2.3.0",
|
||||
"debug": "2.2.0",
|
||||
"diff": "1.4.0",
|
||||
"escape-string-regexp": "1.0.2",
|
||||
"glob": "3.2.3",
|
||||
"growl": "1.8.1",
|
||||
"jade": "0.26.3",
|
||||
"mkdirp": "0.5.0",
|
||||
"supports-color": "1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
|
||||
"integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "0.7.1"
|
||||
}
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz",
|
||||
"integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz",
|
||||
"integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
|
||||
"integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "0.6.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-0.6.2.tgz",
|
||||
"integrity": "sha1-2JwhJMb9wTU9Zai3e/GqxLGTcIw=",
|
||||
"dev": true
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz",
|
||||
"integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=",
|
||||
"dev": true
|
||||
},
|
||||
"optimist": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.1.tgz",
|
||||
"integrity": "sha1-ZoDTBWAZOvWlXrZDlIg+17y5jy4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wordwrap": "0.0.3"
|
||||
}
|
||||
},
|
||||
"requirejs": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.5.tgz",
|
||||
"integrity": "sha512-svnO+aNcR/an9Dpi44C7KSAy5fFGLtmPbaaCeQaklUz8BQhS64tWWIIlvEA5jrWICzlO/X9KSzSeXFnZdBu8nw==",
|
||||
"dev": true
|
||||
},
|
||||
"requizzle": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.1.tgz",
|
||||
"integrity": "sha1-aUPDUwxNmn5G8c3dUcFY/GcM294=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"underscore": "1.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"underscore": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz",
|
||||
"integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"sigmund": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
|
||||
"integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=",
|
||||
"dev": true
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.1.34",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.34.tgz",
|
||||
"integrity": "sha1-p8/omux7FoLDsZjQrPtH19CQVms=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"amdefine": "1.0.1"
|
||||
}
|
||||
},
|
||||
"strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
||||
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
|
||||
"dev": true
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz",
|
||||
"integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=",
|
||||
"dev": true
|
||||
},
|
||||
"taffydb": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz",
|
||||
"integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "2.4.24",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.4.24.tgz",
|
||||
"integrity": "sha1-+tV1XB4Vd2WLsG/5q25UjJW+vW4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"async": "0.2.10",
|
||||
"source-map": "0.1.34",
|
||||
"uglify-to-browserify": "1.0.2",
|
||||
"yargs": "3.5.4"
|
||||
}
|
||||
},
|
||||
"uglify-to-browserify": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
|
||||
"integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
|
||||
"dev": true
|
||||
},
|
||||
"underscore": {
|
||||
"version": "1.8.3",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz",
|
||||
"integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=",
|
||||
"dev": true
|
||||
},
|
||||
"underscore-contrib": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz",
|
||||
"integrity": "sha1-ZltmwkeD+PorGMn4y7Dix9SMJsc=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"underscore": "1.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"underscore": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz",
|
||||
"integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"webworker-threads": {
|
||||
"version": "0.7.13",
|
||||
"resolved": "https://registry.npmjs.org/webworker-threads/-/webworker-threads-0.7.13.tgz",
|
||||
"integrity": "sha1-yEsYtrokElu503NC5E3rgVFi+4M=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bindings": "1.3.0",
|
||||
"nan": "2.7.0"
|
||||
}
|
||||
},
|
||||
"window-size": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
|
||||
"integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=",
|
||||
"dev": true
|
||||
},
|
||||
"wordwrap": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",
|
||||
"integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=",
|
||||
"dev": true
|
||||
},
|
||||
"xfs": {
|
||||
"version": "0.1.8",
|
||||
"resolved": "https://registry.npmjs.org/xfs/-/xfs-0.1.8.tgz",
|
||||
"integrity": "sha1-iHY8QtEdHvlWy9ZNnU2GunM1n9A=",
|
||||
"dev": true
|
||||
},
|
||||
"xmlcreate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz",
|
||||
"integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=",
|
||||
"dev": true
|
||||
},
|
||||
"yargs": {
|
||||
"version": "3.5.4",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.5.4.tgz",
|
||||
"integrity": "sha1-2K/49mXpTDS9JZvevRv68N3TU2E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"camelcase": "1.2.1",
|
||||
"decamelize": "1.2.0",
|
||||
"window-size": "0.1.0",
|
||||
"wordwrap": "0.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"wordwrap": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
|
||||
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "js-md5",
|
||||
"version": "0.4.0",
|
||||
"version": "0.7.0",
|
||||
"description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.",
|
||||
"main": "src/md5.js",
|
||||
"devDependencies": {
|
||||
@@ -9,7 +9,8 @@
|
||||
"jsdoc": "^3.4.0",
|
||||
"mocha": "~2.3.4",
|
||||
"requirejs": "^2.1.22",
|
||||
"uglifyjs": "~2.4.10"
|
||||
"uglify-js": "~2.4.10",
|
||||
"webworker-threads": "^0.7.11"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha tests/node-test.js -r jscoverage",
|
||||
@@ -31,7 +32,7 @@
|
||||
"HMAC"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": "emn178 <emn178@gmail.com>",
|
||||
"author": "Chen, Yi-Cyuan <emn178@gmail.com>",
|
||||
"homepage": "https://github.com/emn178/js-md5",
|
||||
"bugs": {
|
||||
"url": "https://github.com/emn178/js-md5/issues"
|
||||
|
||||
+136
-70
@@ -2,25 +2,35 @@
|
||||
* [js-md5]{@link https://github.com/emn178/js-md5}
|
||||
*
|
||||
* @namespace md5
|
||||
* @version 0.4.0
|
||||
* @author Yi-Cyuan Chen [emn178@gmail.com]
|
||||
* @copyright Yi-Cyuan Chen 2014-2015
|
||||
* @version 0.7.0
|
||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||
* @copyright Chen, Yi-Cyuan 2014-2017
|
||||
* @license MIT
|
||||
*/
|
||||
(function (root) {
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
|
||||
var ERROR = 'input is invalid type';
|
||||
var WINDOW = typeof window === 'object';
|
||||
var root = WINDOW ? window : {};
|
||||
if (root.JS_MD5_NO_WINDOW) {
|
||||
WINDOW = false;
|
||||
}
|
||||
var WEB_WORKER = !WINDOW && typeof self === 'object';
|
||||
var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
|
||||
if (NODE_JS) {
|
||||
root = global;
|
||||
} else if (WEB_WORKER) {
|
||||
root = self;
|
||||
}
|
||||
var COMMON_JS = !root.JS_MD5_TEST && typeof module == 'object' && module.exports;
|
||||
var AMD = typeof define == 'function' && define.amd;
|
||||
var ARRAY_BUFFER = !root.JS_MD5_TEST && typeof ArrayBuffer != 'undefined';
|
||||
var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && typeof module === 'object' && module.exports;
|
||||
var AMD = typeof define === 'function' && define.amd;
|
||||
var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
|
||||
var HEX_CHARS = '0123456789abcdef'.split('');
|
||||
var EXTRA = [128, 32768, 8388608, -2147483648];
|
||||
var SHIFT = [0, 8, 16, 24];
|
||||
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer'];
|
||||
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64'];
|
||||
var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
||||
|
||||
var blocks = [], buffer8;
|
||||
if (ARRAY_BUFFER) {
|
||||
@@ -29,6 +39,18 @@
|
||||
blocks = new Uint32Array(buffer);
|
||||
}
|
||||
|
||||
if (root.JS_MD5_NO_NODE_JS || !Array.isArray) {
|
||||
Array.isArray = function (obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object Array]';
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
* @memberof md5
|
||||
@@ -58,8 +80,18 @@
|
||||
* @example
|
||||
* md5.array('The quick brown fox jumps over the lazy dog');
|
||||
*/
|
||||
/**
|
||||
* @method arrayBuffer
|
||||
* @memberof md5
|
||||
* @description Output hash as ArrayBuffer
|
||||
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
||||
* @returns {ArrayBuffer} ArrayBuffer
|
||||
* @example
|
||||
* md5.arrayBuffer('The quick brown fox jumps over the lazy dog');
|
||||
*/
|
||||
/**
|
||||
* @method buffer
|
||||
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
|
||||
* @memberof md5
|
||||
* @description Output hash as ArrayBuffer
|
||||
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
||||
@@ -67,8 +99,17 @@
|
||||
* @example
|
||||
* md5.buffer('The quick brown fox jumps over the lazy dog');
|
||||
*/
|
||||
/**
|
||||
* @method base64
|
||||
* @memberof md5
|
||||
* @description Output hash as base64 string
|
||||
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
||||
* @returns {String} base64 string
|
||||
* @example
|
||||
* md5.base64('The quick brown fox jumps over the lazy dog');
|
||||
*/
|
||||
var createOutputMethod = function (outputType) {
|
||||
return function(message) {
|
||||
return function (message) {
|
||||
return new Md5(true).update(message)[outputType]();
|
||||
};
|
||||
};
|
||||
@@ -104,7 +145,7 @@
|
||||
method.update = function (message) {
|
||||
return method.create().update(message);
|
||||
};
|
||||
for (var i = 0;i < OUTPUT_TYPES.length;++i) {
|
||||
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
||||
var type = OUTPUT_TYPES[i];
|
||||
method[type] = createOutputMethod(type);
|
||||
}
|
||||
@@ -112,56 +153,25 @@
|
||||
};
|
||||
|
||||
var nodeWrap = function (method) {
|
||||
var crypto, Buffer;
|
||||
try {
|
||||
if (root.JS_MD5_TEST) {
|
||||
throw 'JS_MD5_TEST';
|
||||
}
|
||||
crypto = require('crypto');
|
||||
Buffer = require('buffer').Buffer;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return method;
|
||||
}
|
||||
var crypto = eval("require('crypto')");
|
||||
var Buffer = eval("require('buffer').Buffer");
|
||||
var nodeMethod = function (message) {
|
||||
if (typeof message == 'string') {
|
||||
if (message.length <= nodeMethod.utf8Threshold) {
|
||||
return method(message);
|
||||
} else if (message.length <= nodeMethod.asciiThreshold && !/[^\x00-\x7F]/.test(message)) {
|
||||
return method(message);
|
||||
}
|
||||
if (typeof message === 'string') {
|
||||
return crypto.createHash('md5').update(message, 'utf8').digest('hex');
|
||||
} else if (message.constructor == ArrayBuffer) {
|
||||
} else {
|
||||
if (message === null || message === undefined) {
|
||||
throw ERROR;
|
||||
} else if (message.constructor === ArrayBuffer) {
|
||||
message = new Uint8Array(message);
|
||||
} else if (message.length === undefined || message.length <= nodeMethod.bytesThreshold) {
|
||||
}
|
||||
}
|
||||
if (Array.isArray(message) || ArrayBuffer.isView(message) ||
|
||||
message.constructor === Buffer) {
|
||||
return crypto.createHash('md5').update(new Buffer(message)).digest('hex');
|
||||
} else {
|
||||
return method(message);
|
||||
}
|
||||
return crypto.createHash('md5').update(new Buffer(message)).digest('hex');
|
||||
};
|
||||
|
||||
/**
|
||||
* @member {Number} utf8Threshold
|
||||
* @default 18
|
||||
* @description To use node.js md5 if UTF-8 string length is greater than this value.
|
||||
* @memberof md5
|
||||
*/
|
||||
nodeMethod.utf8Threshold = 18;
|
||||
|
||||
/**
|
||||
* @member {Number} asciiThreshold
|
||||
* @default 60
|
||||
* @description To use node.js md5 if ascii string length is greater than this value.
|
||||
* @memberof md5
|
||||
*/
|
||||
nodeMethod.asciiThreshold = 60;
|
||||
|
||||
/**
|
||||
* @member {Number} bytesThreshold
|
||||
* @default 245
|
||||
* @description To use node.js md5 if bytes length is greater than this value.
|
||||
* @memberof md5
|
||||
*/
|
||||
nodeMethod.bytesThreshold = 245;
|
||||
return nodeMethod;
|
||||
};
|
||||
|
||||
@@ -206,11 +216,25 @@
|
||||
if (this.finalized) {
|
||||
return;
|
||||
}
|
||||
var notString = typeof(message) != 'string';
|
||||
if(notString && message.constructor == root.ArrayBuffer) {
|
||||
|
||||
var notString, type = typeof message;
|
||||
if (type !== 'string') {
|
||||
if (type === 'object') {
|
||||
if (message === null) {
|
||||
throw ERROR;
|
||||
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
||||
message = new Uint8Array(message);
|
||||
} else if (!Array.isArray(message)) {
|
||||
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
||||
throw ERROR;
|
||||
}
|
||||
var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
|
||||
}
|
||||
} else {
|
||||
throw ERROR;
|
||||
}
|
||||
notString = true;
|
||||
}
|
||||
var code, index = 0, i, length = message.length, blocks = this.blocks;
|
||||
var buffer8 = this.buffer8;
|
||||
|
||||
while (index < length) {
|
||||
@@ -225,17 +249,17 @@
|
||||
|
||||
if (notString) {
|
||||
if (ARRAY_BUFFER) {
|
||||
for (i = this.start;index < length && i < 64; ++index) {
|
||||
for (i = this.start; index < length && i < 64; ++index) {
|
||||
buffer8[i++] = message[index];
|
||||
}
|
||||
} else {
|
||||
for (i = this.start;index < length && i < 64; ++index) {
|
||||
for (i = this.start; index < length && i < 64; ++index) {
|
||||
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ARRAY_BUFFER) {
|
||||
for (i = this.start;index < length && i < 64; ++index) {
|
||||
for (i = this.start; index < length && i < 64; ++index) {
|
||||
code = message.charCodeAt(index);
|
||||
if (code < 0x80) {
|
||||
buffer8[i++] = code;
|
||||
@@ -255,7 +279,7 @@
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = this.start;index < length && i < 64; ++index) {
|
||||
for (i = this.start; index < length && i < 64; ++index) {
|
||||
code = message.charCodeAt(index);
|
||||
if (code < 0x80) {
|
||||
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
||||
@@ -307,13 +331,14 @@
|
||||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
||||
}
|
||||
blocks[14] = this.bytes << 3;
|
||||
blocks[15] = this.bytes >> 29;
|
||||
this.hash();
|
||||
};
|
||||
|
||||
Md5.prototype.hash = function () {
|
||||
var a, b, c, d, bc, da, blocks = this.blocks;
|
||||
|
||||
if(this.first) {
|
||||
if (this.first) {
|
||||
a = blocks[0] - 680876937;
|
||||
a = (a << 7 | a >>> 25) - 271733879 << 0;
|
||||
d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;
|
||||
@@ -466,7 +491,7 @@
|
||||
b += (d ^ (c | ~a)) + blocks[9] - 343485551;
|
||||
b = (b << 21 | b >>> 11) + c << 0;
|
||||
|
||||
if(this.first) {
|
||||
if (this.first) {
|
||||
this.h0 = a + 1732584193 << 0;
|
||||
this.h1 = b - 271733879 << 0;
|
||||
this.h2 = c - 1732584194 << 0;
|
||||
@@ -535,7 +560,7 @@
|
||||
* @example
|
||||
* hash.digest();
|
||||
*/
|
||||
Md5.prototype.digest = function() {
|
||||
Md5.prototype.digest = function () {
|
||||
this.finalize();
|
||||
|
||||
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
|
||||
@@ -560,16 +585,16 @@
|
||||
Md5.prototype.array = Md5.prototype.digest;
|
||||
|
||||
/**
|
||||
* @method buffer
|
||||
* @method arrayBuffer
|
||||
* @memberof Md5
|
||||
* @instance
|
||||
* @description Output hash as ArrayBuffer
|
||||
* @returns {ArrayBuffer} ArrayBuffer
|
||||
* @see {@link md5.buffer}
|
||||
* @see {@link md5.arrayBuffer}
|
||||
* @example
|
||||
* hash.buffer();
|
||||
* hash.arrayBuffer();
|
||||
*/
|
||||
Md5.prototype.buffer = function() {
|
||||
Md5.prototype.arrayBuffer = function () {
|
||||
this.finalize();
|
||||
|
||||
var buffer = new ArrayBuffer(16);
|
||||
@@ -581,6 +606,47 @@
|
||||
return buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* @method buffer
|
||||
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
|
||||
* @memberof Md5
|
||||
* @instance
|
||||
* @description Output hash as ArrayBuffer
|
||||
* @returns {ArrayBuffer} ArrayBuffer
|
||||
* @see {@link md5.buffer}
|
||||
* @example
|
||||
* hash.buffer();
|
||||
*/
|
||||
Md5.prototype.buffer = Md5.prototype.arrayBuffer;
|
||||
|
||||
/**
|
||||
* @method base64
|
||||
* @memberof Md5
|
||||
* @instance
|
||||
* @description Output hash as base64 string
|
||||
* @returns {String} base64 string
|
||||
* @see {@link md5.base64}
|
||||
* @example
|
||||
* hash.base64();
|
||||
*/
|
||||
Md5.prototype.base64 = function () {
|
||||
var v1, v2, v3, base64Str = '', bytes = this.array();
|
||||
for (var i = 0; i < 15;) {
|
||||
v1 = bytes[i++];
|
||||
v2 = bytes[i++];
|
||||
v3 = bytes[i++];
|
||||
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
|
||||
BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] +
|
||||
BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] +
|
||||
BASE64_ENCODE_CHAR[v3 & 63];
|
||||
}
|
||||
v1 = bytes[i];
|
||||
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
|
||||
BASE64_ENCODE_CHAR[(v1 << 4) & 63] +
|
||||
'==';
|
||||
return base64Str;
|
||||
};
|
||||
|
||||
var exports = createMethod();
|
||||
|
||||
if (COMMON_JS) {
|
||||
@@ -610,4 +676,4 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
}(this));
|
||||
})();
|
||||
|
||||
+89
-12
@@ -1,23 +1,100 @@
|
||||
md5 = require('../src/md5.js');
|
||||
expect = require('expect.js');
|
||||
require('./test.js');
|
||||
Worker = require('webworker-threads').Worker;
|
||||
|
||||
delete require.cache[require.resolve('../src/md5.js')]
|
||||
delete require.cache[require.resolve('./test.js')]
|
||||
md5 = null
|
||||
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;
|
||||
}
|
||||
|
||||
JS_MD5_TEST = true;
|
||||
require('../src/md5.js');
|
||||
require('./test.js');
|
||||
function runCommonJsTest() {
|
||||
md5 = require('../src/md5.js');
|
||||
require('./test.js');
|
||||
unset();
|
||||
}
|
||||
|
||||
delete require.cache[require.resolve('../src/md5.js')];
|
||||
delete require.cache[require.resolve('./test.js')];
|
||||
md5 = null;
|
||||
function runWindowTest() {
|
||||
window = global;
|
||||
require('../src/md5.js');
|
||||
require('./test.js');
|
||||
unset();
|
||||
}
|
||||
|
||||
define = function(func) {
|
||||
// Node.js env
|
||||
BUFFER = true;
|
||||
runCommonJsTest();
|
||||
|
||||
// Webpack browser env
|
||||
JS_MD5_NO_NODE_JS = true;
|
||||
runCommonJsTest();
|
||||
|
||||
// browser env
|
||||
JS_MD5_NO_NODE_JS = true;
|
||||
JS_MD5_NO_COMMON_JS = true;
|
||||
runWindowTest();
|
||||
|
||||
// browser env and no array buffer
|
||||
JS_MD5_NO_NODE_JS = true;
|
||||
JS_MD5_NO_COMMON_JS = true;
|
||||
JS_MD5_NO_ARRAY_BUFFER = true;
|
||||
runWindowTest();
|
||||
|
||||
// browser env and no isView
|
||||
JS_MD5_NO_NODE_JS = true;
|
||||
JS_MD5_NO_COMMON_JS = true;
|
||||
JS_MD5_NO_ARRAY_BUFFER_IS_VIEW = true;
|
||||
runWindowTest();
|
||||
|
||||
// browser AMD
|
||||
JS_MD5_NO_NODE_JS = true;
|
||||
JS_MD5_NO_COMMON_JS = true;
|
||||
window = global;
|
||||
define = function (func) {
|
||||
md5 = func();
|
||||
require('./test.js');
|
||||
};
|
||||
define.amd = true;
|
||||
|
||||
require('../src/md5.js');
|
||||
unset();
|
||||
|
||||
// webworker
|
||||
WORKER = 'tests/worker.js';
|
||||
SOURCE = 'src/md5.js';
|
||||
|
||||
require('./worker-test.js');
|
||||
|
||||
delete require.cache[require.resolve('./worker-test.js')];
|
||||
|
||||
// cover webworker
|
||||
JS_MD5_NO_WINDOW = true;
|
||||
JS_MD5_NO_NODE_JS = true;
|
||||
WORKER = './worker.js';
|
||||
SOURCE = '../src/md5.js';
|
||||
window = global;
|
||||
self = global;
|
||||
|
||||
Worker = function (file) {
|
||||
require(file);
|
||||
currentWorker = this;
|
||||
|
||||
this.postMessage = function (data) {
|
||||
onmessage({data: data});
|
||||
};
|
||||
}
|
||||
|
||||
postMessage = function (data) {
|
||||
currentWorker.onmessage({data: data});
|
||||
}
|
||||
|
||||
importScripts = function () {};
|
||||
|
||||
md5 = require('../src/md5.js');
|
||||
require('./worker-test.js');
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
<div id="mocha"></div>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
require(['../src/md5.js'], function(md5) {
|
||||
require(['../src/md5.js'], function (md5) {
|
||||
window.md5 = md5;
|
||||
require(['test.js'], function() {
|
||||
require(['test.js'], function () {
|
||||
mocha.checkLeaks();
|
||||
mocha.run();
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
+100
-82
@@ -2,7 +2,7 @@
|
||||
Array.prototype.toHexString = ArrayBuffer.prototype.toHexString = function () {
|
||||
var array = new Uint8Array(this);
|
||||
var hex = '';
|
||||
for (var i = 0;i < array.length;++i) {
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
var c = array[i].toString('16');
|
||||
hex += c.length == 1 ? '0' + c : c;
|
||||
}
|
||||
@@ -42,22 +42,67 @@
|
||||
'd41d8cd98f00b204e9800998ecf8427e': [],
|
||||
'93b885adfe0da089cdf634904fd59f71': [0],
|
||||
'9e107d9d372bb6826bd81d3542a419d6': [84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]
|
||||
},
|
||||
'Uint8Array': {
|
||||
'9e107d9d372bb6826bd81d3542a419d6': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
|
||||
},
|
||||
'Int8Array': {
|
||||
'9e107d9d372bb6826bd81d3542a419d6': new Int8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
|
||||
},
|
||||
'ArrayBuffer': {
|
||||
'93b885adfe0da089cdf634904fd59f71': new ArrayBuffer(1)
|
||||
},
|
||||
'Object': {
|
||||
'd41d8cd98f00b204e9800998ecf8427e': {},
|
||||
'd41d8cd98f00b204e9800998ecf8427e': {what: 'ever'}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var base64TestCases = {
|
||||
'ascii': {
|
||||
'1B2M2Y8AsgTpgAmY7PhCfg==': '',
|
||||
'nhB9nTcrtoJr2B01QqQZ1g==': 'The quick brown fox jumps over the lazy dog',
|
||||
'5NkJwpDQ+xygaP+t3yLL0A==': 'The quick brown fox jumps over the lazy dog.'
|
||||
},
|
||||
'ascii more than 64 bytes': {
|
||||
'9jhy73vJeoqOrbpvCIHeUw==': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
||||
},
|
||||
'UTF8': {
|
||||
'p7rCI5/NyzoGeQPYB3xKBw==': '中文',
|
||||
'7D7b87BaRJ/CBqATjHOcOw==': 'aécio',
|
||||
'uQhpqvEhIQ9sVjlz+oVWUA==': '𠜎'
|
||||
},
|
||||
'UTF8 more than 64 bytes': {
|
||||
'7c5hWxeebim+IxRbd+u9YQ==': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
||||
'rTbJq2aaC6nORtPOkTTeNA==': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
||||
},
|
||||
'special length': {
|
||||
'oRneY+SyOYQn2gbdeAJjsw==': '0123456780123456780123456780123456780123456780123456780',
|
||||
'3a/YTr5jrrxGJrA3pWnXiw==': '01234567801234567801234567801234567801234567801234567801',
|
||||
'nqBNdDYYeXzkZERbV4WmMA==': '0123456780123456780123456780123456780123456780123456780123456780',
|
||||
'ZY2RSuQsSTiHSy54bM2keQ==': '01234567801234567801234567801234567801234567801234567801234567801234567',
|
||||
'oIOjcQ1oV5Px8XmIv+PBdQ==': '012345678012345678012345678012345678012345678012345678012345678012345678',
|
||||
'KyGoQ8/DHIAmoNg1vJG8mA==': '012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678',
|
||||
'0C696XkmTHnhQVWfyfa2XA==': '012345678901234567',
|
||||
'HO2BGvR+rTdIcvzKnXPdcQ==': '012345678901234567890123456789012345678901234567890123456789',
|
||||
'/7gaJDpg2sRZKTAIc+BShw==': '012345678901234567中文',
|
||||
},
|
||||
'Array': {
|
||||
'1B2M2Y8AsgTpgAmY7PhCfg==': [],
|
||||
'k7iFrf4NoInN9jSQT9WfcQ==': [0],
|
||||
'nhB9nTcrtoJr2B01QqQZ1g==': [84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]
|
||||
}
|
||||
};
|
||||
|
||||
if (!(typeof JS_MD5_NO_ARRAY_BUFFER === 'boolean' && JS_MD5_NO_ARRAY_BUFFER)) {
|
||||
testCases['Uint8Array'] = {
|
||||
'9e107d9d372bb6826bd81d3542a419d6': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
|
||||
};
|
||||
testCases['Int8Array'] = {
|
||||
'9e107d9d372bb6826bd81d3542a419d6': new Int8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
|
||||
};
|
||||
testCases['ArrayBuffer'] = {
|
||||
'93b885adfe0da089cdf634904fd59f71': new ArrayBuffer(1)
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof BUFFER === 'boolean' && BUFFER) {
|
||||
testCases['Buffer'] = {
|
||||
'd41d8cd98f00b204e9800998ecf8427e': new Buffer(0),
|
||||
'9e107d9d372bb6826bd81d3542a419d6': new Buffer(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))
|
||||
}
|
||||
}
|
||||
|
||||
var errorTestCases = [null, undefined, { length: 0 }, 0, 1, false, true, NaN, Infinity, function () {}];
|
||||
|
||||
var methods = [
|
||||
{
|
||||
name: 'md5',
|
||||
@@ -79,6 +124,12 @@
|
||||
return md5.digest(message).toHexString();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'md5.arrayBuffer',
|
||||
call: function (message) {
|
||||
return md5.arrayBuffer(message).toHexString();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'md5.buffer',
|
||||
call: function (message) {
|
||||
@@ -118,6 +169,12 @@
|
||||
return md5.update(message).digest().toHexString();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'arrayBuffer',
|
||||
call: function (message) {
|
||||
return md5.update(message).arrayBuffer().toHexString();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'buffer',
|
||||
call: function (message) {
|
||||
@@ -135,6 +192,7 @@
|
||||
}
|
||||
];
|
||||
|
||||
describe('md5', function () {
|
||||
methods.forEach(function (method) {
|
||||
describe('#' + method.name, function () {
|
||||
for (var testCaseName in testCases) {
|
||||
@@ -154,7 +212,6 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('Md5', function () {
|
||||
classMethods.forEach(function (method) {
|
||||
describe('#' + method.name, function () {
|
||||
for (var testCaseName in testCases) {
|
||||
@@ -173,74 +230,35 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('#md5', function () {
|
||||
errorTestCases.forEach(function (testCase) {
|
||||
context('when ' + testCase, function () {
|
||||
it('should throw error', function () {
|
||||
expect(function () {
|
||||
md5(testCase);
|
||||
}).to.throwError(/input is invalid type/);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
// describe('md5', function() {
|
||||
// describe('ascii', function() {
|
||||
// describe('less than 64 bytes', function() {
|
||||
// it('should be successful', function() {
|
||||
// expect(md5('')).to.be('d41d8cd98f00b204e9800998ecf8427e');
|
||||
// expect(md5('The quick brown fox jumps over the lazy dog')).to.be('9e107d9d372bb6826bd81d3542a419d6');
|
||||
// expect(md5('The quick brown fox jumps over the lazy dog.')).to.be('e4d909c290d0fb1ca068ffaddf22cbd0');
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('more than 64 bytes', function() {
|
||||
// it('should be successful', function() {
|
||||
// expect(md5('The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.')).to.be('f63872ef7bc97a8a8eadba6f0881de53');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('UTF8', function() {
|
||||
// describe('less than 64 bytes', function() {
|
||||
// it('should be successful', function() {
|
||||
// expect(md5('中文')).to.be('a7bac2239fcdcb3a067903d8077c4a07');
|
||||
// expect(md5('aécio')).to.be('ec3edbf3b05a449fc206a0138c739c3b');
|
||||
// expect(md5('𠜎')).to.be('b90869aaf121210f6c563973fa855650');
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('more than 64 bytes', function() {
|
||||
// it('should be successful', function() {
|
||||
// expect(md5('訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一')).to.be('edce615b179e6e29be23145b77ebbd61');
|
||||
// expect(md5('訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。')).to.be('ad36c9ab669a0ba9ce46d3ce9134de34');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('special length', function() {
|
||||
// it('should be successful', function() {
|
||||
// expect(md5('0123456780123456780123456780123456780123456780123456780')).to.be('a119de63e4b2398427da06dd780263b3');
|
||||
// expect(md5('01234567801234567801234567801234567801234567801234567801')).to.be('ddafd84ebe63aebc4626b037a569d78b');
|
||||
// expect(md5('0123456780123456780123456780123456780123456780123456780123456780')).to.be('9ea04d743618797ce464445b5785a630');
|
||||
// expect(md5('01234567801234567801234567801234567801234567801234567801234567801234567')).to.be('658d914ae42c4938874b2e786ccda479');
|
||||
// expect(md5('012345678012345678012345678012345678012345678012345678012345678012345678')).to.be('a083a3710d685793f1f17988bfe3c175');
|
||||
// expect(md5('012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678')).to.be('2b21a843cfc31c8026a0d835bc91bc98');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('Array', function() {
|
||||
// describe('Array', function() {
|
||||
// it('should be successful', function() {
|
||||
// expect(md5([])).to.be('d41d8cd98f00b204e9800998ecf8427e');
|
||||
// expect(md5([0])).to.be('93b885adfe0da089cdf634904fd59f71');
|
||||
// expect(md5([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])).to.be('9e107d9d372bb6826bd81d3542a419d6');
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('Uint8Array', function() {
|
||||
// it('should be successful', function() {
|
||||
// expect(md5(new Uint8Array([]))).to.be('d41d8cd98f00b204e9800998ecf8427e');
|
||||
// expect(md5(new Uint8Array(371))).to.be('58f494c2a0fb65332110fb62ae5c4a74');
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('ArrayBuffer', function() {
|
||||
// it('should be successful', function() {
|
||||
// expect(md5(new ArrayBuffer(0))).to.be('d41d8cd98f00b204e9800998ecf8427e');
|
||||
// expect(md5(new ArrayBuffer(1))).to.be('93b885adfe0da089cdf634904fd59f71');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
describe('#bas64', function () {
|
||||
for (var testCaseName in base64TestCases) {
|
||||
var testCase = base64TestCases[testCaseName];
|
||||
context('when ' + testCaseName, function () {
|
||||
for (var hash in testCase) {
|
||||
(function (message, hash) {
|
||||
it('should be equal', function () {
|
||||
expect(md5.base64(message)).to.be(hash);
|
||||
expect(md5.create().update(message).base64()).to.be(hash);
|
||||
expect(md5.update(message).base64()).to.be(hash);
|
||||
});
|
||||
})(testCase[hash], hash);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})(md5);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
(function (Worker, WORKER, SOURCE) {
|
||||
var cases = {
|
||||
'd41d8cd98f00b204e9800998ecf8427e': '',
|
||||
'9e107d9d372bb6826bd81d3542a419d6': 'The quick brown fox jumps over the lazy dog',
|
||||
'e4d909c290d0fb1ca068ffaddf22cbd0': 'The quick brown fox jumps over the lazy dog.'
|
||||
};
|
||||
|
||||
describe('#md5', function () {
|
||||
Object.keys(cases).forEach(function (hash) {
|
||||
it('should be equal', function (done) {
|
||||
var worker = new Worker(WORKER);
|
||||
worker.onmessage = function(event) {
|
||||
expect(event.data).to.be(hash);
|
||||
done();
|
||||
};
|
||||
worker.postMessage(SOURCE);
|
||||
worker.postMessage(cases[hash]);
|
||||
});
|
||||
});
|
||||
});
|
||||
})(Worker, WORKER, SOURCE);
|
||||
@@ -0,0 +1,26 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>MD5</title>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/expect.js/index.js"></script>
|
||||
<script src="../src/md5.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script>
|
||||
WORKER = 'worker.js';
|
||||
SOURCE = '../src/md5.js';
|
||||
mocha.setup('bdd');
|
||||
</script>
|
||||
<script src="worker-test.js"></script>
|
||||
<script>
|
||||
mocha.checkLeaks();
|
||||
mocha.run();
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
var imported = false;
|
||||
onmessage = function(e) {
|
||||
if (imported) {
|
||||
postMessage(md5(e.data));
|
||||
if (typeof exports !== 'undefined') {
|
||||
imported = false;
|
||||
}
|
||||
} else {
|
||||
imported = true;
|
||||
importScripts(e.data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user