* Removed length detection in node.js.

* Deprecated `buffer` and replace by `arrayBuffer`.
pull/3/head v0.4.1
Yi-Cyuan 9 years ago
parent 261e55bd5c
commit 5fcee84417

@ -1,3 +1,8 @@
# v0.4.1 / 2016-03-31
* Removed length detection in node.js.
* Deprecated `buffer` and replace by `arrayBuffer`.
# v0.4.0 / 2015-12-28 # v0.4.0 / 2015-12-28
* Added support for update hash. * Added support for update hash.

@ -1,4 +1,4 @@
Copyright 2014-2015 Yi-Cyuan Chen Copyright 2014-2016 Chen, Yi-Cyuan
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

@ -1,12 +1,13 @@
# js-md5 # js-md5
[![Build Status](https://travis-ci.org/emn178/js-md5.svg?branch=master)](https://travis-ci.org/emn178/js-md5) [![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) [![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/) [![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. A simple MD5 hash function for JavaScript supports UTF-8 encoding.
## Demo ## Demo
[MD5 Online](http://emn178.github.io/online-tools/md5.html) [MD5 Online](http://emn178.github.io/online-tools/md5.html)
[MD5 File Checksum Online](http://emn178.github.io/online-tools/md5_checksum.html) [MD5 File Checksum Online](http://emn178.github.io/online-tools/md5_checksum.html)
## Download ## Download
[Compress](https://raw.github.com/emn178/js-md5/master/build/md5.min.js) [Compress](https://raw.github.com/emn178/js-md5/master/build/md5.min.js)
@ -21,6 +22,9 @@ For node.js, you can use this command to install:
npm install js-md5 npm install js-md5
## Notice
`buffer` method is deprecated. This maybe confuse with Buffer in node.js. Please use `arrayBuffer` instead.
## Usage ## Usage
You could use like this: You could use like this:
```JavaScript ```JavaScript
@ -59,7 +63,8 @@ md5(''); // d41d8cd98f00b204e9800998ecf8427e
md5.hex(''); // d41d8cd98f00b204e9800998ecf8427e md5.hex(''); // d41d8cd98f00b204e9800998ecf8427e
md5.array(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126] 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.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 ## Benchmark
@ -71,4 +76,4 @@ The project is released under the [MIT license](http://www.opensource.org/licens
## Contact ## Contact
The project's website is located at https://github.com/emn178/js-md5 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,9 +1,8 @@
{ {
"name": "js-md5", "name": "js-md5",
"version": "0.4.0", "version": "0.4.1",
"main": ["src/md5.js"], "main": ["src/md5.js"],
"ignore": [ "ignore": [
"samples",
"tests" "tests"
] ]
} }

6
build/md5.min.js vendored

File diff suppressed because one or more lines are too long

@ -91,7 +91,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line168">line 168</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line149">line 149</a>
</li></ul></dd> </li></ul></dd>
@ -198,7 +198,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line550">line 550</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line531">line 531</a>
</li></ul></dd> </li></ul></dd>
@ -263,6 +263,122 @@
<h4 class="name" id="arrayBuffer"><span class="type-signature"></span>arrayBuffer<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="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#line543">line 543</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> <h4 class="name" id="buffer"><span class="type-signature"></span>buffer<span class="signature">()</span><span class="type-signature"> &rarr; {ArrayBuffer}</span></h4>
@ -302,6 +418,8 @@
<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>
@ -314,7 +432,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line562">line 562</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line565">line 565</a>
</li></ul></dd> </li></ul></dd>
@ -430,7 +548,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line528">line 528</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line509">line 509</a>
</li></ul></dd> </li></ul></dd>
@ -546,7 +664,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line483">line 483</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line464">line 464</a>
</li></ul></dd> </li></ul></dd>
@ -662,7 +780,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line516">line 516</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line497">line 497</a>
</li></ul></dd> </li></ul></dd>
@ -836,7 +954,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line196">line 196</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line177">line 177</a>
</li></ul></dd> </li></ul></dd>
@ -913,7 +1031,7 @@
<br class="clear"> <br class="clear">
<footer> <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.0</a> on Thu Mar 31 2016 16:24:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -210,7 +210,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line589">line 589</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line583">line 583</a>
</li></ul></dd> </li></ul></dd>
@ -259,16 +259,7 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>md5(''); // d41d8cd98f00b204e9800998ecf8427e <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>
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>
@ -294,7 +285,7 @@ md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.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.0</a> on Thu Mar 31 2016 16:24:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -44,12 +44,14 @@
<section> <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> <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> <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>
<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> <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>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> <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>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'); <pre class="prettyprint source lang-JavaScript"><code>md5('Message to hash');
var hash = md5.create(); var hash = md5.create();
hash.update('Message to hash'); hash.update('Message to hash');
@ -74,9 +76,10 @@ md5(''); // d41d8cd98f00b204e9800998ecf8427e
md5.hex(''); // d41d8cd98f00b204e9800998ecf8427e md5.hex(''); // d41d8cd98f00b204e9800998ecf8427e
md5.array(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126] 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.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> md5.arrayBuffer(''); // ArrayBuffer
md5.buffer(''); // ArrayBuffer, deprecated, This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.</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>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> <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> </section>
@ -93,7 +96,7 @@ md5.buffer(''); // ArrayBuffer</code></pre><h2>Benchmark</h2><p><a href="http://
<br class="clear"> <br class="clear">
<footer> <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.0</a> on Thu Mar 31 2016 16:24:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -68,14 +68,14 @@
<dt class="tag-author">Author:</dt> <dt class="tag-author">Author:</dt>
<dd class="tag-author"> <dd class="tag-author">
<ul> <ul>
<li>Yi-Cyuan Chen [emn178@gmail.com]</li> <li>Chen, Yi-Cyuan [emn178@gmail.com]</li>
</ul> </ul>
</dd> </dd>
<dt class="tag-copyright">Copyright:</dt> <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-2016</li></ul></dd>
@ -115,107 +115,90 @@
<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>
<h3 class="subsection-title">Methods</h3>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Number</span>
</li>
</ul>
<dl class="details">
<h4 class="name" id=".array"><span class="type-signature">(static) </span>array<span class="signature">(message)</span><span class="type-signature"> &rarr; {Array}</span></h4>
<div class="description">
Output hash as bytes array
</div>
<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>
<h5>Parameters:</h5>
<table class="params">
</dl> <thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<h4 class="name" id=".bytesThreshold"><span class="type-signature">(static) </span>bytesThreshold<span class="type-signature"> :Number</span></h4> <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>
<div class="description">
To use node.js md5 if bytes length is greater than this value.
</div>
</td>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Number</span>
<td class="description last">message to hash</td>
</tr>
</tbody>
</table>
</li>
</ul>
@ -245,17 +228,12 @@
<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> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line158">line 158</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line52">line 52</a>
</li></ul></dd> </li></ul></dd>
@ -271,102 +249,56 @@
<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> <h5>Returns:</h5>
<ul>
<li>
<span class="param-type">Number</span>
</li>
</ul>
<dl class="details">
<div class="param-desc">
Bytes array
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
<dt class="tag-default">Default Value:</dt>
<dd class="tag-default"><ul class="dummy">
<li>18</li>
</ul></dd>
</dd>
<dt class="tag-source">Source:</dt> </dl>
<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>
<h5>Example</h5>
</dl> <pre class="prettyprint"><code>md5.array('The quick brown fox jumps over the lazy dog');</code></pre>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".array"><span class="type-signature">(static) </span>array<span class="signature">(message)</span><span class="type-signature"> &rarr; {Array}</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>
<div class="description"> <div class="description">
Output hash as bytes array Output hash as ArrayBuffer
</div> </div>
@ -468,7 +400,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line52">line 52</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line61">line 61</a>
</li></ul></dd> </li></ul></dd>
@ -495,7 +427,7 @@
<div class="param-desc"> <div class="param-desc">
Bytes array ArrayBuffer
</div> </div>
@ -506,7 +438,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Array</span> <span class="param-type">ArrayBuffer</span>
</dd> </dd>
@ -517,7 +449,7 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>md5.array('The quick brown fox jumps over the lazy dog');</code></pre> <pre class="prettyprint"><code>md5.arrayBuffer('The quick brown fox jumps over the lazy dog');</code></pre>
@ -623,6 +555,8 @@
<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>
@ -635,7 +569,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line61">line 61</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line70">line 70</a>
</li></ul></dd> </li></ul></dd>
@ -744,7 +678,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line76">line 76</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line86">line 86</a>
</li></ul></dd> </li></ul></dd>
@ -1127,9 +1061,7 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>md5.hex('The quick brown fox jumps over the lazy dog'); <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>
// 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>
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line84">line 84</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line94">line 94</a>
</li></ul></dd> </li></ul></dd>
@ -1296,10 +1228,7 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>var hash = md5.update('The quick brown fox jumps over the lazy dog'); <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>
// equal to
var hash = md5.create();
hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
@ -1325,7 +1254,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.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.0</a> on Thu Mar 31 2016 16:24:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -31,8 +31,8 @@
* *
* @namespace md5 * @namespace md5
* @version 0.4.0 * @version 0.4.0
* @author Yi-Cyuan Chen [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Yi-Cyuan Chen 2014-2015 * @copyright Chen, Yi-Cyuan 2014-2016
* @license MIT * @license MIT
*/ */
(function (root) { (function (root) {
@ -48,7 +48,7 @@
var HEX_CHARS = '0123456789abcdef'.split(''); var HEX_CHARS = '0123456789abcdef'.split('');
var EXTRA = [128, 32768, 8388608, -2147483648]; var EXTRA = [128, 32768, 8388608, -2147483648];
var SHIFT = [0, 8, 16, 24]; var SHIFT = [0, 8, 16, 24];
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer']; var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer'];
var blocks = [], buffer8; var blocks = [], buffer8;
if (ARRAY_BUFFER) { if (ARRAY_BUFFER) {
@ -86,8 +86,18 @@
* @example * @example
* md5.array('The quick brown fox jumps over the lazy dog'); * 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 * @method buffer
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
* @memberof md5 * @memberof md5
* @description Output hash as ArrayBuffer * @description Output hash as ArrayBuffer
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
@ -96,9 +106,9 @@
* md5.buffer('The quick brown fox jumps over the lazy dog'); * md5.buffer('The quick brown fox jumps over the lazy dog');
*/ */
var createOutputMethod = function (outputType) { var createOutputMethod = function (outputType) {
return function(message) { return function (message) {
return new Md5(true).update(message)[outputType](); return new Md5(true).update(message)[outputType]();
} };
}; };
/** /**
@ -153,45 +163,16 @@
} }
var nodeMethod = function (message) { var nodeMethod = function (message) {
if (typeof message == 'string') { 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);
}
return crypto.createHash('md5').update(message, 'utf8').digest('hex'); return crypto.createHash('md5').update(message, 'utf8').digest('hex');
} else if (message.constructor == ArrayBuffer) { } else if (message.constructor == ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (message.length === undefined || message.length &lt;= nodeMethod.bytesThreshold) { } else if (message.length === undefined) {
return method(message); return method(message);
} }
return crypto.createHash('md5').update(new Buffer(message)).digest('hex'); 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; return nodeMethod;
} };
/** /**
* Md5 class * Md5 class
@ -235,7 +216,7 @@
return; return;
} }
var notString = typeof(message) != 'string'; 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); message = new Uint8Array(message);
} }
var code, index = 0, i, length = message.length || 0, blocks = this.blocks; var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
@ -341,7 +322,7 @@
Md5.prototype.hash = function () { Md5.prototype.hash = function () {
var a, b, c, d, bc, da, blocks = this.blocks; var a, b, c, d, bc, da, blocks = this.blocks;
if(this.first) { if (this.first) {
a = blocks[0] - 680876937; a = blocks[0] - 680876937;
a = (a &lt;&lt; 7 | a >>> 25) - 271733879 &lt;&lt; 0; a = (a &lt;&lt; 7 | a >>> 25) - 271733879 &lt;&lt; 0;
d = (-1732584194 ^ a &amp; 2004318071) + blocks[1] - 117830708; d = (-1732584194 ^ a &amp; 2004318071) + blocks[1] - 117830708;
@ -494,7 +475,7 @@
b += (d ^ (c | ~a)) + blocks[9] - 343485551; b += (d ^ (c | ~a)) + blocks[9] - 343485551;
b = (b &lt;&lt; 21 | b >>> 11) + c &lt;&lt; 0; 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.h0 = a + 1732584193 &lt;&lt; 0;
this.h1 = b - 271733879 &lt;&lt; 0; this.h1 = b - 271733879 &lt;&lt; 0;
this.h2 = c - 1732584194 &lt;&lt; 0; this.h2 = c - 1732584194 &lt;&lt; 0;
@ -563,7 +544,7 @@
* @example * @example
* hash.digest(); * hash.digest();
*/ */
Md5.prototype.digest = function() { Md5.prototype.digest = function () {
this.finalize(); this.finalize();
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3; var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
@ -588,16 +569,16 @@
Md5.prototype.array = Md5.prototype.digest; Md5.prototype.array = Md5.prototype.digest;
/** /**
* @method buffer * @method arrayBuffer
* @memberof Md5 * @memberof Md5
* @instance * @instance
* @description Output hash as ArrayBuffer * @description Output hash as ArrayBuffer
* @returns {ArrayBuffer} ArrayBuffer * @returns {ArrayBuffer} ArrayBuffer
* @see {@link md5.buffer} * @see {@link md5.arrayBuffer}
* @example * @example
* hash.buffer(); * hash.arrayBuffer();
*/ */
Md5.prototype.buffer = function() { Md5.prototype.arrayBuffer = function () {
this.finalize(); this.finalize();
var buffer = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
@ -609,6 +590,19 @@
return buffer; 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(); var exports = createMethod();
if (COMMON_JS) { if (COMMON_JS) {
@ -655,7 +649,7 @@
<br class="clear"> <br class="clear">
<footer> <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.0</a> on Thu Mar 31 2016 16:24:20 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -1,6 +1,6 @@
{ {
"name": "js-md5", "name": "js-md5",
"version": "0.4.0", "version": "0.4.1",
"description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.", "description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.",
"main": "src/md5.js", "main": "src/md5.js",
"devDependencies": { "devDependencies": {
@ -31,7 +31,7 @@
"HMAC" "HMAC"
], ],
"license": "MIT", "license": "MIT",
"author": "emn178 <emn178@gmail.com>", "author": "Chen, Yi-Cyuan <emn178@gmail.com>",
"homepage": "https://github.com/emn178/js-md5", "homepage": "https://github.com/emn178/js-md5",
"bugs": { "bugs": {
"url": "https://github.com/emn178/js-md5/issues" "url": "https://github.com/emn178/js-md5/issues"

@ -3,8 +3,8 @@
* *
* @namespace md5 * @namespace md5
* @version 0.4.0 * @version 0.4.0
* @author Yi-Cyuan Chen [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Yi-Cyuan Chen 2014-2015 * @copyright Chen, Yi-Cyuan 2014-2016
* @license MIT * @license MIT
*/ */
(function (root) { (function (root) {
@ -20,7 +20,7 @@
var HEX_CHARS = '0123456789abcdef'.split(''); var HEX_CHARS = '0123456789abcdef'.split('');
var EXTRA = [128, 32768, 8388608, -2147483648]; var EXTRA = [128, 32768, 8388608, -2147483648];
var SHIFT = [0, 8, 16, 24]; var SHIFT = [0, 8, 16, 24];
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer']; var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer'];
var blocks = [], buffer8; var blocks = [], buffer8;
if (ARRAY_BUFFER) { if (ARRAY_BUFFER) {
@ -58,8 +58,18 @@
* @example * @example
* md5.array('The quick brown fox jumps over the lazy dog'); * 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 * @method buffer
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
* @memberof md5 * @memberof md5
* @description Output hash as ArrayBuffer * @description Output hash as ArrayBuffer
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
@ -68,7 +78,7 @@
* md5.buffer('The quick brown fox jumps over the lazy dog'); * md5.buffer('The quick brown fox jumps over the lazy dog');
*/ */
var createOutputMethod = function (outputType) { var createOutputMethod = function (outputType) {
return function(message) { return function (message) {
return new Md5(true).update(message)[outputType](); return new Md5(true).update(message)[outputType]();
}; };
}; };
@ -125,43 +135,14 @@
} }
var nodeMethod = function (message) { var nodeMethod = function (message) {
if (typeof message == 'string') { 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);
}
return crypto.createHash('md5').update(message, 'utf8').digest('hex'); return crypto.createHash('md5').update(message, 'utf8').digest('hex');
} else if (message.constructor == ArrayBuffer) { } else if (message.constructor == ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (message.length === undefined || message.length <= nodeMethod.bytesThreshold) { } else if (message.length === undefined) {
return method(message); return method(message);
} }
return crypto.createHash('md5').update(new Buffer(message)).digest('hex'); 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; return nodeMethod;
}; };
@ -207,7 +188,7 @@
return; return;
} }
var notString = typeof(message) != 'string'; var notString = typeof(message) != 'string';
if(notString && message.constructor == root.ArrayBuffer) { if (notString && message.constructor == root.ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} }
var code, index = 0, i, length = message.length || 0, blocks = this.blocks; var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
@ -313,7 +294,7 @@
Md5.prototype.hash = function () { Md5.prototype.hash = function () {
var a, b, c, d, bc, da, blocks = this.blocks; var a, b, c, d, bc, da, blocks = this.blocks;
if(this.first) { if (this.first) {
a = blocks[0] - 680876937; a = blocks[0] - 680876937;
a = (a << 7 | a >>> 25) - 271733879 << 0; a = (a << 7 | a >>> 25) - 271733879 << 0;
d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708; d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;
@ -466,7 +447,7 @@
b += (d ^ (c | ~a)) + blocks[9] - 343485551; b += (d ^ (c | ~a)) + blocks[9] - 343485551;
b = (b << 21 | b >>> 11) + c << 0; b = (b << 21 | b >>> 11) + c << 0;
if(this.first) { if (this.first) {
this.h0 = a + 1732584193 << 0; this.h0 = a + 1732584193 << 0;
this.h1 = b - 271733879 << 0; this.h1 = b - 271733879 << 0;
this.h2 = c - 1732584194 << 0; this.h2 = c - 1732584194 << 0;
@ -535,7 +516,7 @@
* @example * @example
* hash.digest(); * hash.digest();
*/ */
Md5.prototype.digest = function() { Md5.prototype.digest = function () {
this.finalize(); this.finalize();
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3; var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
@ -560,16 +541,16 @@
Md5.prototype.array = Md5.prototype.digest; Md5.prototype.array = Md5.prototype.digest;
/** /**
* @method buffer * @method arrayBuffer
* @memberof Md5 * @memberof Md5
* @instance * @instance
* @description Output hash as ArrayBuffer * @description Output hash as ArrayBuffer
* @returns {ArrayBuffer} ArrayBuffer * @returns {ArrayBuffer} ArrayBuffer
* @see {@link md5.buffer} * @see {@link md5.arrayBuffer}
* @example * @example
* hash.buffer(); * hash.arrayBuffer();
*/ */
Md5.prototype.buffer = function() { Md5.prototype.arrayBuffer = function () {
this.finalize(); this.finalize();
var buffer = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
@ -581,6 +562,19 @@
return buffer; 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(); var exports = createMethod();
if (COMMON_JS) { if (COMMON_JS) {

@ -14,7 +14,7 @@ delete require.cache[require.resolve('../src/md5.js')];
delete require.cache[require.resolve('./test.js')]; delete require.cache[require.resolve('./test.js')];
md5 = null; md5 = null;
define = function(func) { define = function (func) {
md5 = func(); md5 = func();
require('./test.js'); require('./test.js');
}; };

@ -12,12 +12,12 @@
<div id="mocha"></div> <div id="mocha"></div>
<script> <script>
mocha.setup('bdd'); mocha.setup('bdd');
require(['../src/md5.js'], function(md5) { require(['../src/md5.js'], function (md5) {
window.md5 = md5; window.md5 = md5;
require(['test.js'], function() { require(['test.js'], function () {
mocha.checkLeaks(); mocha.checkLeaks();
mocha.run(); mocha.run();
}) });
}); });
</script> </script>
</body> </body>

@ -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 = [ var methods = [
{ {
name: 'md5', name: 'md5',
@ -79,6 +86,12 @@
return md5.digest(message).toHexString(); return md5.digest(message).toHexString();
} }
}, },
{
name: 'md5.arrayBuffer',
call: function (message) {
return md5.arrayBuffer(message).toHexString();
}
},
{ {
name: 'md5.buffer', name: 'md5.buffer',
call: function (message) { call: function (message) {
@ -118,6 +131,12 @@
return md5.update(message).digest().toHexString(); return md5.update(message).digest().toHexString();
} }
}, },
{
name: 'arrayBuffer',
call: function (message) {
return md5.update(message).arrayBuffer().toHexString();
}
},
{ {
name: 'buffer', name: 'buffer',
call: function (message) { 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); })(md5);

Loading…
Cancel
Save