mirror of
https://github.com/emn178/js-md5.git
synced 2026-08-12 20:31:43 +08:00
* Removed length detection in node.js.
* Deprecated `buffer` and replace by `arrayBuffer`.
This commit is contained in:
@@ -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
|
||||
|
||||
* Added support for update hash.
|
||||
|
||||
+1
-1
@@ -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
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
[](https://travis-ci.org/emn178/js-md5)
|
||||
[](https://coveralls.io/r/emn178/js-md5?branch=master)
|
||||
[](https://nodei.co/npm/js-md5/)
|
||||
|
||||
A simple MD5 hash function for JavaScript supports UTF-8 encoding.
|
||||
|
||||
## Demo
|
||||
@@ -21,6 +22,9 @@ For node.js, you can use this command to install:
|
||||
|
||||
npm install js-md5
|
||||
|
||||
## Notice
|
||||
`buffer` method is deprecated. This maybe confuse with Buffer in node.js. Please use `arrayBuffer` instead.
|
||||
|
||||
## Usage
|
||||
You could use like this:
|
||||
```JavaScript
|
||||
@@ -59,7 +63,8 @@ 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
|
||||
@@ -71,4 +76,4 @@ The project is released under the [MIT license](http://www.opensource.org/licens
|
||||
|
||||
## Contact
|
||||
The project's website is located at https://github.com/emn178/js-md5
|
||||
Author: Yi-Cyuan Chen (emn178@gmail.com)
|
||||
Author: Chen, Yi-Cyuan (emn178@gmail.com)
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"name": "js-md5",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"main": ["src/md5.js"],
|
||||
"ignore": [
|
||||
"samples",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+3
-3
File diff suppressed because one or more lines are too long
+127
-9
@@ -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#line149">line 149</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#line531">line 531</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"> → {ArrayBuffer}</span></h4>
|
||||
<h4 class="name" id="arrayBuffer"><span class="type-signature"></span>arrayBuffer<span class="signature">()</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -314,7 +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#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"> → {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#line565">line 565</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#line509">line 509</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#line464">line 464</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#line497">line 497</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#line177">line 177</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.0</a> on Thu Mar 31 2016 16:24:21 GMT+0800 (CST)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
+3
-12
@@ -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#line583">line 583</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
-6
@@ -44,12 +44,14 @@
|
||||
|
||||
<section>
|
||||
<article><h1>js-md5</h1><p><a href="https://travis-ci.org/emn178/js-md5"><img src="https://travis-ci.org/emn178/js-md5.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://coveralls.io/r/emn178/js-md5?branch=master"><img src="https://coveralls.io/repos/emn178/js-md5/badge.svg?branch=master" alt="Coverage Status"></a><br><a href="https://nodei.co/npm/js-md5/"><img src="https://nodei.co/npm/js-md5.png?stars&downloads" alt="NPM"></a><br>A simple MD5 hash function for JavaScript supports UTF-8 encoding.</p>
|
||||
<h2>Demo</h2><p><a href="http://emn178.github.io/online-tools/md5.html">MD5 Online</a><br><a href="http://emn178.github.io/online-tools/md5_checksum.html">MD5 File Checksum Online</a> </p>
|
||||
<a href="https://coveralls.io/r/emn178/js-md5?branch=master"><img src="https://coveralls.io/repos/emn178/js-md5/badge.svg?branch=master" alt="Coverage Status"></a><br><a href="https://nodei.co/npm/js-md5/"><img src="https://nodei.co/npm/js-md5.png?stars&downloads" alt="NPM"></a></p>
|
||||
<p>A simple MD5 hash function for JavaScript supports UTF-8 encoding.</p>
|
||||
<h2>Demo</h2><p><a href="http://emn178.github.io/online-tools/md5.html">MD5 Online</a><br><a href="http://emn178.github.io/online-tools/md5_checksum.html">MD5 File Checksum Online</a></p>
|
||||
<h2>Download</h2><p><a href="https://raw.github.com/emn178/js-md5/master/build/md5.min.js">Compress</a><br><a href="https://raw.github.com/emn178/js-md5/master/src/md5.js">Uncompress</a></p>
|
||||
<h2>Installation</h2><p>You can also install js-md5 by using Bower.</p>
|
||||
<pre class="prettyprint source"><code>bower install md5</code></pre><p>For node.js, you can use this command to install:</p>
|
||||
<pre class="prettyprint source"><code>npm install js-md5</code></pre><h2>Usage</h2><p>You could use like this:</p>
|
||||
<pre class="prettyprint source"><code>npm install js-md5</code></pre><h2>Notice</h2><p><code>buffer</code> method is deprecated. This maybe confuse with Buffer in node.js. Please use <code>arrayBuffer</code> instead.</p>
|
||||
<h2>Usage</h2><p>You could use like this:</p>
|
||||
<pre class="prettyprint source lang-JavaScript"><code>md5('Message to hash');
|
||||
var hash = md5.create();
|
||||
hash.update('Message to hash');
|
||||
@@ -74,9 +76,10 @@ md5(''); // d41d8cd98f00b204e9800998ecf8427e
|
||||
md5.hex(''); // d41d8cd98f00b204e9800998ecf8427e
|
||||
md5.array(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]
|
||||
md5.digest(''); // [212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]
|
||||
md5.buffer(''); // ArrayBuffer</code></pre><h2>Benchmark</h2><p><a href="http://jsperf.com/md5-shootout/81">UTF8</a><br><a href="http://jsperf.com/md5-shootout/82">ASCII</a></p>
|
||||
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>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>
|
||||
|
||||
|
||||
@@ -93,7 +96,7 @@ md5.buffer(''); // ArrayBuffer</code></pre><h2>Benchmark</h2><p><a href="http://
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Dec 28 2015 15:48:48 GMT+0800 (CST)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Mar 31 2016 16:24:21 GMT+0800 (CST)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
+177
-248
@@ -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-2016</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>
|
||||
@@ -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"> → {ArrayBuffer}</span></h4>
|
||||
<h4 class="name" id=".arrayBuffer"><span class="type-signature">(static) </span>arrayBuffer<span class="signature">(message)</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
|
||||
|
||||
|
||||
|
||||
@@ -658,6 +423,175 @@
|
||||
|
||||
|
||||
|
||||
<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"> → {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#line70">line 70</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
@@ -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#line86">line 86</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#line94">line 94</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">
|
||||
|
||||
|
||||
+39
-45
@@ -31,8 +31,8 @@
|
||||
*
|
||||
* @namespace md5
|
||||
* @version 0.4.0
|
||||
* @author Yi-Cyuan Chen [emn178@gmail.com]
|
||||
* @copyright Yi-Cyuan Chen 2014-2015
|
||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||
* @copyright Chen, Yi-Cyuan 2014-2016
|
||||
* @license MIT
|
||||
*/
|
||||
(function (root) {
|
||||
@@ -48,7 +48,7 @@
|
||||
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 +86,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 +106,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]();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -153,45 +163,16 @@
|
||||
}
|
||||
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);
|
||||
}
|
||||
return crypto.createHash('md5').update(message, 'utf8').digest('hex');
|
||||
} 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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Md5 class
|
||||
@@ -235,7 +216,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;
|
||||
@@ -341,7 +322,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;
|
||||
@@ -494,7 +475,7 @@
|
||||
b += (d ^ (c | ~a)) + blocks[9] - 343485551;
|
||||
b = (b << 21 | b >>> 11) + c << 0;
|
||||
|
||||
if(this.first) {
|
||||
if (this.first) {
|
||||
this.h0 = a + 1732584193 << 0;
|
||||
this.h1 = b - 271733879 << 0;
|
||||
this.h2 = c - 1732584194 << 0;
|
||||
@@ -563,7 +544,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 +569,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 +590,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) {
|
||||
@@ -655,7 +649,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.0</a> on Thu Mar 31 2016 16:24:20 GMT+0800 (CST)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "js-md5",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"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"
|
||||
|
||||
+36
-42
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* @namespace md5
|
||||
* @version 0.4.0
|
||||
* @author Yi-Cyuan Chen [emn178@gmail.com]
|
||||
* @copyright Yi-Cyuan Chen 2014-2015
|
||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||
* @copyright Chen, Yi-Cyuan 2014-2016
|
||||
* @license MIT
|
||||
*/
|
||||
(function (root) {
|
||||
@@ -20,7 +20,7 @@
|
||||
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 +58,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 +78,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]();
|
||||
};
|
||||
};
|
||||
@@ -125,43 +135,14 @@
|
||||
}
|
||||
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);
|
||||
}
|
||||
return crypto.createHash('md5').update(message, 'utf8').digest('hex');
|
||||
} 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 +188,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;
|
||||
@@ -313,7 +294,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 +447,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 +516,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 +541,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 +562,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) {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ delete require.cache[require.resolve('../src/md5.js')];
|
||||
delete require.cache[require.resolve('./test.js')];
|
||||
md5 = null;
|
||||
|
||||
define = function(func) {
|
||||
define = function (func) {
|
||||
md5 = func();
|
||||
require('./test.js');
|
||||
};
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
<div id="mocha"></div>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
require(['../src/md5.js'], function(md5) {
|
||||
require(['../src/md5.js'], function (md5) {
|
||||
window.md5 = md5;
|
||||
require(['test.js'], function() {
|
||||
require(['test.js'], function () {
|
||||
mocha.checkLeaks();
|
||||
mocha.run();
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
+19
-69
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user