3 Commits
Author SHA1 Message Date
Chen, Yi-Cyuan 8b9a23ce32 Fixed root is undefined in some special environment. #7 2017-01-18 09:44:08 +08:00
Chen Yi-Cyuan da009f933f update comment version 2016-07-30 20:39:20 +08:00
Yi-Cyuan 5fcee84417 * Removed length detection in node.js.
* Deprecated `buffer` and replace by `arrayBuffer`.
2016-03-31 16:25:38 +08:00
19 changed files with 598 additions and 589 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
/node_modules/
/tests/
node_modules/
+2 -2
View File
@@ -1,2 +1,2 @@
covreporter
node_modules
/node_modules/
/covreporter/
+3 -5
View File
@@ -1,10 +1,8 @@
language: node_js
node_js:
- "4.1"
- "4.0"
- "0.12"
- "0.11"
- "0.10"
- "0.12.15"
- "4.5"
- "6.5.0"
before_install:
- npm install coveralls
- npm install mocha-lcov-reporter
+54 -37
View File
@@ -1,49 +1,66 @@
# 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.4.2 / 2017-01-18
### Fixed
- `root` is undefined in some special environment. #7
# v0.3.0 / 2015-03-07
## v0.4.1 / 2016-03-31
### Removed
- length detection in node.js.
### Deprecated
- `buffer` and replace by `arrayBuffer`.
* Support byte Array, Uint8Array and ArrayBuffer input.
## v0.4.0 / 2015-12-28
### Added
- support for update hash.
- support for bytes array output.
- support for ArrayBuffer output.
- support for AMD.
# v0.2.2 / 2015-02-01
## v0.3.0 / 2015-03-07
### Added
- support byte Array, Uint8Array and ArrayBuffer input.
* Fixed bug when special length.
* Improve performance for node.js.
## v0.2.2 / 2015-02-01
### Fixed
- bug when special length.
### Improve
- performance for node.js.
# v0.2.1 / 2015-01-13
## v0.2.1 / 2015-01-13
### Improve
- performance.
* Improve performance.
## v0.2.0 / 2015-01-12
### Removed
- ascii parameter.
### Improve
- performance.
# v0.2.0 / 2015-01-12
## v0.1.4 / 2015-01-11
### Improve
- performance.
### Added
- test cases.
* Remove ascii parameter.
* Improve performance.
## v0.1.3 / 2015-01-05
### Added
- bower package.
- travis.
- coveralls.
### Improved
- performance.
### Fixed
- JSHint warnings.
# v0.1.4 / 2015-01-11
## v0.1.2 / 2014-07-27
### Fixed
- accents bug
* Improve performance.
* Add test case.
## v0.1.1 / 2014-01-05
### Changed
- license
# v0.1.3 / 2015-01-05
* Improve performance.
* Add bower package.
* Fixed JSHint warnings.
* Add travis.
* Add coveralls.
# v0.1.2 / 2014-07-27
Fixed accents bug
# v0.1.1 / 2014-01-05
Update license
# v0.1.0 / 2014-01-04
Initial release
## v0.1.0 / 2014-01-04
### Added
- initial release
+1 -1
View File
@@ -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
+7 -6
View File
@@ -2,6 +2,7 @@
[![Build Status](https://travis-ci.org/emn178/js-md5.svg?branch=master)](https://travis-ci.org/emn178/js-md5)
[![Coverage Status](https://coveralls.io/repos/emn178/js-md5/badge.svg?branch=master)](https://coveralls.io/r/emn178/js-md5?branch=master)
[![NPM](https://nodei.co/npm/js-md5.png?stars&downloads)](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,13 @@ 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.
```
## 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
View File
@@ -1,9 +1,8 @@
{
"name": "js-md5",
"version": "0.4.0",
"version": "0.4.2",
"main": ["src/md5.js"],
"ignore": [
"samples",
"tests"
]
}
+4 -4
View File
File diff suppressed because one or more lines are too long
+127 -9
View File
@@ -91,7 +91,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#line141">line 141</a>
</li></ul></dd>
@@ -198,7 +198,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#line523">line 523</a>
</li></ul></dd>
@@ -263,7 +263,7 @@
<h4 class="name" id="buffer"><span class="type-signature"></span>buffer<span class="signature">()</span><span class="type-signature"> &rarr; {ArrayBuffer}</span></h4>
<h4 class="name" id="arrayBuffer"><span class="type-signature"></span>arrayBuffer<span class="signature">()</span><span class="type-signature"> &rarr; {ArrayBuffer}</span></h4>
@@ -314,7 +314,125 @@
<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#line535">line 535</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="buffer"><span class="type-signature"></span>buffer<span class="signature">()</span><span class="type-signature"> &rarr; {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#line557">line 557</a>
</li></ul></dd>
@@ -430,7 +548,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#line501">line 501</a>
</li></ul></dd>
@@ -546,7 +664,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#line456">line 456</a>
</li></ul></dd>
@@ -662,7 +780,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#line489">line 489</a>
</li></ul></dd>
@@ -836,7 +954,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#line169">line 169</a>
</li></ul></dd>
@@ -913,7 +1031,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.4.3</a> on Wed Jan 18 2017 09:43:27 GMT+0800 (CST)
</footer>
<script> prettyPrint(); </script>
+3 -12
View File
@@ -210,7 +210,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#line575">line 575</a>
</li></ul></dd>
@@ -259,16 +259,7 @@
<h5>Example</h5>
<pre class="prettyprint"><code>md5(''); // d41d8cd98f00b204e9800998ecf8427e
md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6
md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0
// It also supports UTF-8 encoding
md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07
// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`
md5([]); // d41d8cd98f00b204e9800998ecf8427e
md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
<pre class="prettyprint"><code>md5(''); // d41d8cd98f00b204e9800998ecf8427e
md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6
md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0
@@ -294,7 +285,7 @@ md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
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)
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Md5_.html">Md5</a></li></ul><h3>Namespaces</h3><ul><li><a href="md5.html">md5</a></li></ul><h3>Global</h3><ul><li><a href="global.html#md5%2508">md5</a></li></ul>
+9 -7
View File
@@ -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&amp;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&amp;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,9 @@ 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.</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 +95,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.4.3</a> on Wed Jan 18 2017 09:43:27 GMT+0800 (CST)
</footer>
<script> prettyPrint(); </script>
+182 -253
View File
@@ -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.4.2</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,241 +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>
<h3 class="subsection-title">Methods</h3>
@@ -468,7 +233,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#line53">line 53</a>
</li></ul></dd>
@@ -526,7 +291,7 @@
<h4 class="name" id=".buffer"><span class="type-signature">(static) </span>buffer<span class="signature">(message)</span><span class="type-signature"> &rarr; {ArrayBuffer}</span></h4>
<h4 class="name" id=".arrayBuffer"><span class="type-signature">(static) </span>arrayBuffer<span class="signature">(message)</span><span class="type-signature"> &rarr; {ArrayBuffer}</span></h4>
@@ -635,7 +400,176 @@
<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#line62">line 62</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.arrayBuffer('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"> &rarr; {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#line71">line 71</a>
</li></ul></dd>
@@ -744,7 +678,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#line87">line 87</a>
</li></ul></dd>
@@ -911,7 +845,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#line44">line 44</a>
</li></ul></dd>
@@ -1078,7 +1012,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#line33">line 33</a>
</li></ul></dd>
@@ -1127,9 +1061,7 @@
<h5>Example</h5>
<pre class="prettyprint"><code>md5.hex('The quick brown fox jumps over the lazy dog');
// equal to
md5('The quick brown fox jumps over the lazy dog');</code></pre>
<pre class="prettyprint"><code>md5.hex('The quick brown fox jumps over the lazy dog');
// equal to
md5('The quick brown fox jumps over the lazy dog');</code></pre>
@@ -1247,7 +1179,7 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line84">line 84</a>
<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#line95">line 95</a>
</li></ul></dd>
@@ -1296,10 +1228,7 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
<pre class="prettyprint"><code>var hash = md5.update('The quick brown fox jumps over the lazy dog');
// equal to
var hash = md5.create();
hash.update('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');
// equal to
@@ -1325,7 +1254,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Md5_.html">Md5</a></li></ul><h3>Namespaces</h3><ul><li><a href="md5.html">md5</a></li></ul><h3>Global</h3><ul><li><a href="global.html#md5%2508">md5</a></li></ul>
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)
</nav>
<br class="clear">
+56 -70
View File
@@ -30,25 +30,26 @@
* [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.4.2
* @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' &amp;&amp; process.versions &amp;&amp; process.versions.node;
var root = typeof window === 'object' ? window : {};
var NODE_JS = !root.JS_MD5_NO_NODE_JS &amp;&amp; typeof process === 'object' &amp;&amp; process.versions &amp;&amp; process.versions.node;
if (NODE_JS) {
root = global;
}
var COMMON_JS = !root.JS_MD5_TEST &amp;&amp; typeof module == 'object' &amp;&amp; module.exports;
var AMD = typeof define == 'function' &amp;&amp; define.amd;
var ARRAY_BUFFER = !root.JS_MD5_TEST &amp;&amp; typeof ArrayBuffer != 'undefined';
var COMMON_JS = !root.JS_MD5_NO_COMMON_JS &amp;&amp; typeof module === 'object' &amp;&amp; module.exports;
var AMD = typeof define === 'function' &amp;&amp; define.amd;
var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER &amp;&amp; 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'];
var blocks = [], buffer8;
if (ARRAY_BUFFER) {
@@ -86,8 +87,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
@@ -96,9 +107,9 @@
* md5.buffer('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 +143,7 @@
method.update = function (message) {
return method.create().update(message);
};
for (var i = 0;i &lt; OUTPUT_TYPES.length;++i) {
for (var i = 0; i &lt; OUTPUT_TYPES.length; ++i) {
var type = OUTPUT_TYPES[i];
method[type] = createOutputMethod(type);
}
@@ -140,58 +151,20 @@
};
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 = require('crypto');
var Buffer = require('buffer').Buffer;
var nodeMethod = function (message) {
if (typeof message == 'string') {
if (message.length &lt;= nodeMethod.utf8Threshold) {
return method(message);
} else if (message.length &lt;= nodeMethod.asciiThreshold &amp;&amp; !/[^\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.constructor === ArrayBuffer) {
message = new Uint8Array(message);
} else if (message.length === undefined || message.length &lt;= nodeMethod.bytesThreshold) {
} else if (message.length === undefined) {
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
@@ -235,7 +208,7 @@
return;
}
var notString = typeof(message) != 'string';
if(notString &amp;&amp; message.constructor == root.ArrayBuffer) {
if (notString &amp;&amp; message.constructor == root.ArrayBuffer) {
message = new Uint8Array(message);
}
var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
@@ -253,17 +226,17 @@
if (notString) {
if (ARRAY_BUFFER) {
for (i = this.start;index &lt; length &amp;&amp; i &lt; 64; ++index) {
for (i = this.start; index &lt; length &amp;&amp; i &lt; 64; ++index) {
buffer8[i++] = message[index];
}
} else {
for (i = this.start;index &lt; length &amp;&amp; i &lt; 64; ++index) {
for (i = this.start; index &lt; length &amp;&amp; i &lt; 64; ++index) {
blocks[i >> 2] |= message[index] &lt;&lt; SHIFT[i++ &amp; 3];
}
}
} else {
if (ARRAY_BUFFER) {
for (i = this.start;index &lt; length &amp;&amp; i &lt; 64; ++index) {
for (i = this.start; index &lt; length &amp;&amp; i &lt; 64; ++index) {
code = message.charCodeAt(index);
if (code &lt; 0x80) {
buffer8[i++] = code;
@@ -283,7 +256,7 @@
}
}
} else {
for (i = this.start;index &lt; length &amp;&amp; i &lt; 64; ++index) {
for (i = this.start; index &lt; length &amp;&amp; i &lt; 64; ++index) {
code = message.charCodeAt(index);
if (code &lt; 0x80) {
blocks[i >> 2] |= code &lt;&lt; SHIFT[i++ &amp; 3];
@@ -341,7 +314,7 @@
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 &lt;&lt; 7 | a >>> 25) - 271733879 &lt;&lt; 0;
d = (-1732584194 ^ a &amp; 2004318071) + blocks[1] - 117830708;
@@ -494,7 +467,7 @@
b += (d ^ (c | ~a)) + blocks[9] - 343485551;
b = (b &lt;&lt; 21 | b >>> 11) + c &lt;&lt; 0;
if(this.first) {
if (this.first) {
this.h0 = a + 1732584193 &lt;&lt; 0;
this.h1 = b - 271733879 &lt;&lt; 0;
this.h2 = c - 1732584194 &lt;&lt; 0;
@@ -563,7 +536,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 +561,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 +582,19 @@
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;
var exports = createMethod();
if (COMMON_JS) {
@@ -638,7 +624,7 @@
});
}
}
}(this));
})();
</code></pre>
</article>
</section>
@@ -655,7 +641,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.4.3</a> on Wed Jan 18 2017 09:43:27 GMT+0800 (CST)
</footer>
<script> prettyPrint(); </script>
+34 -33
View File
@@ -153,7 +153,7 @@ h1
margin: 12px 24px 20px;
}
h2, h3
h2, h3.subsection-title
{
font-size: 30px;
font-weight: 700;
@@ -161,6 +161,13 @@ h2, h3
margin-bottom: 12px;
}
h3
{
font-size: 24px;
letter-spacing: -0.5px;
margin-bottom: 12px;
}
h4
{
font-size: 18px;
@@ -185,6 +192,32 @@ h6
font-style: italic;
}
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 { color: #999; }
.ancestors a
{
@@ -296,44 +329,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
{
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "js-md5",
"version": "0.4.0",
"version": "0.4.2",
"description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.",
"main": "src/md5.js",
"devDependencies": {
@@ -31,7 +31,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"
+53 -67
View File
@@ -2,25 +2,26 @@
* [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.4.2
* @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 root = typeof window === 'object' ? window : {};
var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) {
root = global;
}
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'];
var blocks = [], buffer8;
if (ARRAY_BUFFER) {
@@ -58,8 +59,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
@@ -68,7 +79,7 @@
* md5.buffer('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 +115,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 +123,18 @@
};
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 = require('crypto');
var Buffer = 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.constructor === ArrayBuffer) {
message = new Uint8Array(message);
} else if (message.length === undefined || message.length <= nodeMethod.bytesThreshold) {
} else if (message.length === undefined) {
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;
};
@@ -207,7 +180,7 @@
return;
}
var notString = typeof(message) != 'string';
if(notString && message.constructor == root.ArrayBuffer) {
if (notString && message.constructor == root.ArrayBuffer) {
message = new Uint8Array(message);
}
var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
@@ -225,17 +198,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 +228,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];
@@ -313,7 +286,7 @@
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 +439,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 +508,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 +533,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 +554,19 @@
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;
var exports = createMethod();
if (COMMON_JS) {
@@ -610,4 +596,4 @@
});
}
}
}(this));
})();
+34 -3
View File
@@ -1,12 +1,26 @@
md5 = require('../src/md5.js');
// Node.js env
expect = require('expect.js');
md5 = require('../src/md5.js');
require('./test.js');
delete require.cache[require.resolve('../src/md5.js')]
delete require.cache[require.resolve('./test.js')]
md5 = null
JS_MD5_TEST = true;
// Webpack browser env
JS_MD5_NO_NODE_JS = true;
window = global;
md5 = require('../src/md5.js');
require('./test.js');
delete require.cache[require.resolve('../src/md5.js')];
delete require.cache[require.resolve('./test.js')];
md5 = null;
// browser env
JS_MD5_NO_NODE_JS = true;
JS_MD5_NO_COMMON_JS = true;
window = global;
require('../src/md5.js');
require('./test.js');
@@ -14,7 +28,24 @@ delete require.cache[require.resolve('../src/md5.js')];
delete require.cache[require.resolve('./test.js')];
md5 = null;
define = function(func) {
// browser env and no array buffer
JS_MD5_NO_NODE_JS = true;
JS_MD5_NO_COMMON_JS = true;
JS_MD5_NO_ARRAY_BUFFER = true;
window = global;
require('../src/md5.js');
require('./test.js');
delete require.cache[require.resolve('../src/md5.js')];
delete require.cache[require.resolve('./test.js')];
md5 = null;
// browser AMD
JS_MD5_NO_NODE_JS = true;
JS_MD5_NO_COMMON_JS = true;
JS_MD5_NO_ARRAY_BUFFER = false;
window = global;
define = function (func) {
md5 = func();
require('./test.js');
};
+3 -3
View File
@@ -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>
+20 -70
View File
@@ -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;
}
@@ -58,6 +58,13 @@
}
};
if (typeof process == 'object') {
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 methods = [
{
name: 'md5',
@@ -79,6 +86,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 +131,12 @@
return md5.update(message).digest().toHexString();
}
},
{
name: 'arrayBuffer',
call: function (message) {
return md5.update(message).arrayBuffer().toHexString();
}
},
{
name: 'buffer',
call: function (message) {
@@ -174,73 +193,4 @@
});
});
});
// 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');
// });
// });
// });
})(md5);