Added support base64 string output.

pull/12/merge v0.6.0
Chen Yi-Cyuan 8 years ago
parent 2bdc4894fc
commit b808ed4605

@ -1,5 +1,9 @@
# Change Log # Change Log
## v0.6.0 / 2017-07-28
### Added
- support base64 string output.
## v0.5.0 / 2017-07-14 ## v0.5.0 / 2017-07-14
### Added ### Added
- support for web worker. #11 - support for web worker. #11

@ -65,6 +65,7 @@ md5.array(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248
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.arrayBuffer(''); // ArrayBuffer md5.arrayBuffer(''); // ArrayBuffer
md5.buffer(''); // ArrayBuffer, deprecated, This maybe confuse with Buffer in node.js. Please use arrayBuffer instead. md5.buffer(''); // ArrayBuffer, deprecated, This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
md5.base64(''); // 1B2M2Y8AsgTpgAmY7PhCfg==
``` ```
## License ## License

@ -1,6 +1,6 @@
{ {
"name": "js-md5", "name": "js-md5",
"version": "0.5.0", "version": "0.6.0",
"main": ["src/md5.js"], "main": ["src/md5.js"],
"ignore": [ "ignore": [
"tests" "tests"

4
build/md5.min.js vendored

File diff suppressed because one or more lines are too long

@ -28,7 +28,7 @@
<header> <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> </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> <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"> <div class="description">
This is internal class. This is internal class.
</div> </div>
@ -91,7 +93,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line162">line 162</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line172">line 172</a>
</li></ul></dd> </li></ul></dd>
@ -125,6 +127,8 @@
</div> </div>
@ -140,6 +144,8 @@
<h3 class="subsection-title">Methods</h3> <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"> &rarr; {Array}</span></h4> <h4 class="name" id="array"><span class="type-signature"></span>array<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4>
<div class="description"> <div class="description">
Output hash as bytes array Output hash as bytes array
</div> </div>
@ -198,7 +206,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line556">line 556</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line566">line 566</a>
</li></ul></dd> </li></ul></dd>
@ -252,6 +260,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>hash.array();</code></pre> <pre class="prettyprint"><code>hash.array();</code></pre>
@ -263,12 +273,14 @@
<h4 class="name" id="arrayBuffer"><span class="type-signature"></span>arrayBuffer<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>
<div class="description"> <div class="description">
Output hash as ArrayBuffer Output hash as ArrayBuffer
</div> </div>
@ -314,7 +326,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line568">line 568</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line578">line 578</a>
</li></ul></dd> </li></ul></dd>
@ -368,6 +380,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>hash.arrayBuffer();</code></pre> <pre class="prettyprint"><code>hash.arrayBuffer();</code></pre>
@ -379,12 +393,134 @@
<h4 class="name" id="base64"><span class="type-signature"></span>base64<span class="signature">()</span><span class="type-signature"> &rarr; {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#line613">line 613</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"> &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>
<div class="description"> <div class="description">
Output hash as ArrayBuffer Output hash as ArrayBuffer
</div> </div>
@ -432,7 +568,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line590">line 590</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line600">line 600</a>
</li></ul></dd> </li></ul></dd>
@ -486,6 +622,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>hash.buffer();</code></pre> <pre class="prettyprint"><code>hash.buffer();</code></pre>
@ -497,12 +635,14 @@
<h4 class="name" id="digest"><span class="type-signature"></span>digest<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> <h4 class="name" id="digest"><span class="type-signature"></span>digest<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4>
<div class="description"> <div class="description">
Output hash as bytes array Output hash as bytes array
</div> </div>
@ -548,7 +688,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line534">line 534</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line544">line 544</a>
</li></ul></dd> </li></ul></dd>
@ -602,6 +742,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>hash.digest();</code></pre> <pre class="prettyprint"><code>hash.digest();</code></pre>
@ -613,12 +755,14 @@
<h4 class="name" id="hex"><span class="type-signature"></span>hex<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id="hex"><span class="type-signature"></span>hex<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4>
<div class="description"> <div class="description">
Output hash as hex string Output hash as hex string
</div> </div>
@ -664,7 +808,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line489">line 489</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line499">line 499</a>
</li></ul></dd> </li></ul></dd>
@ -718,6 +862,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>hash.hex();</code></pre> <pre class="prettyprint"><code>hash.hex();</code></pre>
@ -729,12 +875,14 @@
<h4 class="name" id="toString"><span class="type-signature"></span>toString<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id="toString"><span class="type-signature"></span>toString<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4>
<div class="description"> <div class="description">
Output hash as hex string Output hash as hex string
</div> </div>
@ -780,7 +928,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line522">line 522</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line532">line 532</a>
</li></ul></dd> </li></ul></dd>
@ -834,6 +982,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>hash.toString();</code></pre> <pre class="prettyprint"><code>hash.toString();</code></pre>
@ -845,12 +995,14 @@
<h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">(message)</span><span class="type-signature"> &rarr; {<a href="Md5_.html">Md5</a>}</span></h4> <h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">(message)</span><span class="type-signature"> &rarr; {<a href="Md5_.html">Md5</a>}</span></h4>
<div class="description"> <div class="description">
Update hash Update hash
</div> </div>
@ -954,7 +1106,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line190">line 190</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line200">line 200</a>
</li></ul></dd> </li></ul></dd>
@ -1015,6 +1167,8 @@
</article> </article>
</section> </section>
@ -1031,7 +1185,7 @@
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Fri Jul 14 2017 12:58:59 GMT+0800 (CST) Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -94,6 +94,8 @@
<h3 class="subsection-title">Methods</h3> <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"> &rarr; {String}</span></h4> <h4 class="name" id="md5%08"><span class="type-signature"></span>md5<span class="signature">(message)</span><span class="type-signature"> &rarr; {String}</span></h4>
<div class="description"> <div class="description">
Md5 hash function, export to global in browsers. Md5 hash function, export to global in browsers.
</div> </div>
@ -210,7 +214,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line608">line 608</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line646">line 646</a>
</li></ul></dd> </li></ul></dd>
@ -257,9 +261,20 @@
<h5>Example</h5> <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
// It also supports UTF-8 encoding
md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07
// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`
md5([]); // d41d8cd98f00b204e9800998ecf8427e
md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
@ -285,7 +300,7 @@
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Fri Jul 14 2017 12:58:59 GMT+0800 (CST) Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -77,7 +77,8 @@ 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.arrayBuffer(''); // ArrayBuffer 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> 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> <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>
@ -95,7 +96,7 @@ md5.buffer(''); // ArrayBuffer, deprecated, This maybe confuse with Buffer in no
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Fri Jul 14 2017 12:58:59 GMT+0800 (CST) Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -47,7 +47,7 @@
<dt class="tag-version">Version:</dt> <dt class="tag-version">Version:</dt>
<dd class="tag-version"><ul class="dummy"><li>0.5.0</li></ul></dd> <dd class="tag-version"><ul class="dummy"><li>0.6.0</li></ul></dd>
@ -117,6 +117,8 @@
<h3 class="subsection-title">Methods</h3> <h3 class="subsection-title">Methods</h3>
@ -124,12 +126,14 @@
<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=".array"><span class="type-signature">(static) </span>array<span class="signature">(message)</span><span class="type-signature"> &rarr; {Array}</span></h4>
<div class="description"> <div class="description">
Output hash as bytes array Output hash as bytes array
</div> </div>
@ -233,7 +237,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line67">line 67</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line68">line 68</a>
</li></ul></dd> </li></ul></dd>
@ -280,6 +284,8 @@
<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.array('The quick brown fox jumps over the lazy dog');</code></pre>
@ -291,12 +297,14 @@
<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> <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 ArrayBuffer Output hash as ArrayBuffer
</div> </div>
@ -400,7 +408,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line76">line 76</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line77">line 77</a>
</li></ul></dd> </li></ul></dd>
@ -447,6 +455,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>md5.arrayBuffer('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>
@ -458,12 +468,185 @@
<h4 class="name" id=".base64"><span class="type-signature">(static) </span>base64<span class="signature">(message)</span><span class="type-signature"> &rarr; {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#line96">line 96</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"> &rarr; {ArrayBuffer}</span></h4> <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"> <div class="description">
Output hash as ArrayBuffer Output hash as ArrayBuffer
</div> </div>
@ -569,7 +752,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line85">line 85</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line86">line 86</a>
</li></ul></dd> </li></ul></dd>
@ -616,6 +799,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>md5.buffer('The quick brown fox jumps over the lazy dog');</code></pre> <pre class="prettyprint"><code>md5.buffer('The quick brown fox jumps over the lazy dog');</code></pre>
@ -627,12 +812,14 @@
<h4 class="name" id=".create"><span class="type-signature">(static) </span>create<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Md5_.html">Md5</a>}</span></h4> <h4 class="name" id=".create"><span class="type-signature">(static) </span>create<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Md5_.html">Md5</a>}</span></h4>
<div class="description"> <div class="description">
Create Md5 object Create Md5 object
</div> </div>
@ -678,7 +865,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line101">line 101</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line111">line 111</a>
</li></ul></dd> </li></ul></dd>
@ -725,6 +912,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>var hash = md5.create();</code></pre> <pre class="prettyprint"><code>var hash = md5.create();</code></pre>
@ -736,12 +925,14 @@
<h4 class="name" id=".digest"><span class="type-signature">(static) </span>digest<span class="signature">(message)</span><span class="type-signature"> &rarr; {Array}</span></h4> <h4 class="name" id=".digest"><span class="type-signature">(static) </span>digest<span class="signature">(message)</span><span class="type-signature"> &rarr; {Array}</span></h4>
<div class="description"> <div class="description">
Output hash as bytes array Output hash as bytes array
</div> </div>
@ -845,7 +1036,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line58">line 58</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line59">line 59</a>
</li></ul></dd> </li></ul></dd>
@ -892,6 +1083,8 @@
<h5>Example</h5> <h5>Example</h5>
<pre class="prettyprint"><code>md5.digest('The quick brown fox jumps over the lazy dog');</code></pre> <pre class="prettyprint"><code>md5.digest('The quick brown fox jumps over the lazy dog');</code></pre>
@ -903,12 +1096,14 @@
<h4 class="name" id=".hex"><span class="type-signature">(static) </span>hex<span class="signature">(message)</span><span class="type-signature"> &rarr; {String}</span></h4> <h4 class="name" id=".hex"><span class="type-signature">(static) </span>hex<span class="signature">(message)</span><span class="type-signature"> &rarr; {String}</span></h4>
<div class="description"> <div class="description">
Output hash as hex string Output hash as hex string
</div> </div>
@ -1012,7 +1207,7 @@
<dt class="tag-source">Source:</dt> <dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li> <dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line47">line 47</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line48">line 48</a>
</li></ul></dd> </li></ul></dd>
@ -1059,9 +1254,14 @@
<h5>Example</h5> <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>
@ -1076,6 +1276,7 @@
<div class="description"> <div class="description">
Create and update Md5 object Create and update Md5 object
</div> </div>
@ -1179,7 +1380,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#line109">line 109</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line119">line 119</a>
</li></ul></dd> </li></ul></dd>
@ -1226,9 +1427,14 @@
<h5>Example</h5> <h5>Example</h5>
<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> <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>
@ -1254,7 +1460,7 @@
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Fri Jul 14 2017 12:58:59 GMT+0800 (CST) Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -30,7 +30,7 @@
* [js-md5]{@link https://github.com/emn178/js-md5} * [js-md5]{@link https://github.com/emn178/js-md5}
* *
* @namespace md5 * @namespace md5
* @version 0.5.0 * @version 0.6.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017 * @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT * @license MIT
@ -57,7 +57,8 @@
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', 'arrayBuffer']; var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64'];
var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
var blocks = [], buffer8; var blocks = [], buffer8;
if (ARRAY_BUFFER) { if (ARRAY_BUFFER) {
@ -120,6 +121,15 @@
* @example * @example
* md5.buffer('The quick brown fox jumps over the lazy dog'); * 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) { var createOutputMethod = function (outputType) {
return function (message) { return function (message) {
return new Md5(true).update(message)[outputType](); return new Md5(true).update(message)[outputType]();
@ -530,21 +540,21 @@
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;
return HEX_CHARS[(h0 >> 4) &amp; 0x0F] + HEX_CHARS[h0 &amp; 0x0F] + return HEX_CHARS[(h0 >> 4) &amp; 0x0F] + HEX_CHARS[h0 &amp; 0x0F] +
HEX_CHARS[(h0 >> 12) &amp; 0x0F] + HEX_CHARS[(h0 >> 8) &amp; 0x0F] + HEX_CHARS[(h0 >> 12) &amp; 0x0F] + HEX_CHARS[(h0 >> 8) &amp; 0x0F] +
HEX_CHARS[(h0 >> 20) &amp; 0x0F] + HEX_CHARS[(h0 >> 16) &amp; 0x0F] + HEX_CHARS[(h0 >> 20) &amp; 0x0F] + HEX_CHARS[(h0 >> 16) &amp; 0x0F] +
HEX_CHARS[(h0 >> 28) &amp; 0x0F] + HEX_CHARS[(h0 >> 24) &amp; 0x0F] + HEX_CHARS[(h0 >> 28) &amp; 0x0F] + HEX_CHARS[(h0 >> 24) &amp; 0x0F] +
HEX_CHARS[(h1 >> 4) &amp; 0x0F] + HEX_CHARS[h1 &amp; 0x0F] + HEX_CHARS[(h1 >> 4) &amp; 0x0F] + HEX_CHARS[h1 &amp; 0x0F] +
HEX_CHARS[(h1 >> 12) &amp; 0x0F] + HEX_CHARS[(h1 >> 8) &amp; 0x0F] + HEX_CHARS[(h1 >> 12) &amp; 0x0F] + HEX_CHARS[(h1 >> 8) &amp; 0x0F] +
HEX_CHARS[(h1 >> 20) &amp; 0x0F] + HEX_CHARS[(h1 >> 16) &amp; 0x0F] + HEX_CHARS[(h1 >> 20) &amp; 0x0F] + HEX_CHARS[(h1 >> 16) &amp; 0x0F] +
HEX_CHARS[(h1 >> 28) &amp; 0x0F] + HEX_CHARS[(h1 >> 24) &amp; 0x0F] + HEX_CHARS[(h1 >> 28) &amp; 0x0F] + HEX_CHARS[(h1 >> 24) &amp; 0x0F] +
HEX_CHARS[(h2 >> 4) &amp; 0x0F] + HEX_CHARS[h2 &amp; 0x0F] + HEX_CHARS[(h2 >> 4) &amp; 0x0F] + HEX_CHARS[h2 &amp; 0x0F] +
HEX_CHARS[(h2 >> 12) &amp; 0x0F] + HEX_CHARS[(h2 >> 8) &amp; 0x0F] + HEX_CHARS[(h2 >> 12) &amp; 0x0F] + HEX_CHARS[(h2 >> 8) &amp; 0x0F] +
HEX_CHARS[(h2 >> 20) &amp; 0x0F] + HEX_CHARS[(h2 >> 16) &amp; 0x0F] + HEX_CHARS[(h2 >> 20) &amp; 0x0F] + HEX_CHARS[(h2 >> 16) &amp; 0x0F] +
HEX_CHARS[(h2 >> 28) &amp; 0x0F] + HEX_CHARS[(h2 >> 24) &amp; 0x0F] + HEX_CHARS[(h2 >> 28) &amp; 0x0F] + HEX_CHARS[(h2 >> 24) &amp; 0x0F] +
HEX_CHARS[(h3 >> 4) &amp; 0x0F] + HEX_CHARS[h3 &amp; 0x0F] + HEX_CHARS[(h3 >> 4) &amp; 0x0F] + HEX_CHARS[h3 &amp; 0x0F] +
HEX_CHARS[(h3 >> 12) &amp; 0x0F] + HEX_CHARS[(h3 >> 8) &amp; 0x0F] + HEX_CHARS[(h3 >> 12) &amp; 0x0F] + HEX_CHARS[(h3 >> 8) &amp; 0x0F] +
HEX_CHARS[(h3 >> 20) &amp; 0x0F] + HEX_CHARS[(h3 >> 16) &amp; 0x0F] + HEX_CHARS[(h3 >> 20) &amp; 0x0F] + HEX_CHARS[(h3 >> 16) &amp; 0x0F] +
HEX_CHARS[(h3 >> 28) &amp; 0x0F] + HEX_CHARS[(h3 >> 24) &amp; 0x0F]; HEX_CHARS[(h3 >> 28) &amp; 0x0F] + HEX_CHARS[(h3 >> 24) &amp; 0x0F];
}; };
/** /**
@ -628,6 +638,34 @@
*/ */
Md5.prototype.buffer = Md5.prototype.arrayBuffer; 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 &lt; 15;) {
v1 = bytes[i++];
v2 = bytes[i++];
v3 = bytes[i++];
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
BASE64_ENCODE_CHAR[(v1 &lt;&lt; 4 | v2 >>> 4) &amp; 63] +
BASE64_ENCODE_CHAR[(v2 &lt;&lt; 2 | v3 >>> 6) &amp; 63] +
BASE64_ENCODE_CHAR[v3 &amp; 63];
}
v1 = bytes[i];
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
BASE64_ENCODE_CHAR[(v1 &lt;&lt; 4) &amp; 63] +
'==';
return base64Str;
};
var exports = createMethod(); var exports = createMethod();
if (COMMON_JS) { if (COMMON_JS) {
@ -674,7 +712,7 @@
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Fri Jul 14 2017 12:58:59 GMT+0800 (CST) Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

@ -78,6 +78,10 @@ article dl {
margin-bottom: 40px; margin-bottom: 40px;
} }
article img {
max-width: 100%;
}
section section
{ {
display: block; display: block;
@ -218,8 +222,8 @@ thead tr
th { border-right: 1px solid #aaa; } th { border-right: 1px solid #aaa; }
tr > th:last-child { border-right: 1px solid #ddd; } tr > th:last-child { border-right: 1px solid #ddd; }
.ancestors { color: #999; } .ancestors, .attribs { color: #999; }
.ancestors a .ancestors a, .attribs a
{ {
color: #999 !important; color: #999 !important;
text-decoration: none; text-decoration: none;

@ -1,6 +1,6 @@
{ {
"name": "js-md5", "name": "js-md5",
"version": "0.5.0", "version": "0.6.0",
"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": {
@ -9,7 +9,7 @@
"jsdoc": "^3.4.0", "jsdoc": "^3.4.0",
"mocha": "~2.3.4", "mocha": "~2.3.4",
"requirejs": "^2.1.22", "requirejs": "^2.1.22",
"uglifyjs": "~2.4.10", "uglify-js": "~2.4.10",
"webworker-threads": "^0.7.11" "webworker-threads": "^0.7.11"
}, },
"scripts": { "scripts": {

@ -2,7 +2,7 @@
* [js-md5]{@link https://github.com/emn178/js-md5} * [js-md5]{@link https://github.com/emn178/js-md5}
* *
* @namespace md5 * @namespace md5
* @version 0.5.0 * @version 0.6.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017 * @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT * @license MIT
@ -29,7 +29,8 @@
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', 'arrayBuffer']; var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64'];
var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
var blocks = [], buffer8; var blocks = [], buffer8;
if (ARRAY_BUFFER) { if (ARRAY_BUFFER) {
@ -92,6 +93,15 @@
* @example * @example
* md5.buffer('The quick brown fox jumps over the lazy dog'); * 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) { var createOutputMethod = function (outputType) {
return function (message) { return function (message) {
return new Md5(true).update(message)[outputType](); return new Md5(true).update(message)[outputType]();
@ -502,21 +512,21 @@
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;
return HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + return HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] + HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +
HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] + HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +
HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] + HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +
HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] + HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +
HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] + HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +
HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] + HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +
HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] + HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +
HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] + HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +
HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] + HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +
HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] + HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +
HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] + HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +
HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F]; HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F];
}; };
/** /**
@ -600,6 +610,34 @@
*/ */
Md5.prototype.buffer = Md5.prototype.arrayBuffer; 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(); var exports = createMethod();
if (COMMON_JS) { if (COMMON_JS) {

@ -45,6 +45,43 @@
} }
}; };
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)) { if (!(typeof JS_MD5_NO_ARRAY_BUFFER === 'boolean' && JS_MD5_NO_ARRAY_BUFFER)) {
testCases['Uint8Array'] = { 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]) '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])
@ -205,5 +242,23 @@
}); });
}); });
}); });
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); })(md5);

Loading…
Cancel
Save