### Added

- Modern and lite builds generated from the same source.
- support ESM.
- Set up GitHub release action / provenance

### Fixed
- Fix uploading coverage to coveralls
- fix recognize environment is node when use browserfs
This commit is contained in:
Yi-Cyuan Chen
2026-07-20 10:19:42 +08:00
parent 6f25176e1e
commit b02f0d93f3
37 changed files with 10048 additions and 1073 deletions
+10 -10
View File
@@ -93,7 +93,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line779">line 779</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line803">line 803</a>
</li></ul></dd>
@@ -224,7 +224,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#line704">line 704</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line722">line 722</a>
</li></ul></dd>
@@ -351,7 +351,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#line716">line 716</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line734">line 734</a>
</li></ul></dd>
@@ -478,7 +478,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#line751">line 751</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line772">line 772</a>
</li></ul></dd>
@@ -607,7 +607,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#line738">line 738</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line756">line 756</a>
</li></ul></dd>
@@ -734,7 +734,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#line682">line 682</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line700">line 700</a>
</li></ul></dd>
@@ -861,7 +861,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#line637">line 637</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line655">line 655</a>
</li></ul></dd>
@@ -988,7 +988,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#line670">line 670</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line688">line 688</a>
</li></ul></dd>
@@ -1173,7 +1173,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#line345">line 345</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line363">line 363</a>
</li></ul></dd>
@@ -1254,7 +1254,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 27 2023 21:32:04 GMT+0800 (台北標準時間)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time)
</footer>
<script> prettyPrint(); </script>
+11 -11
View File
@@ -47,7 +47,7 @@
<dt class="tag-version">Version:</dt>
<dd class="tag-version"><ul class="dummy"><li>0.8.0</li></ul></dd>
<dd class="tag-version"><ul class="dummy"><li>0.9.0</li></ul></dd>
@@ -75,7 +75,7 @@
<dt class="tag-copyright">Copyright:</dt>
<dd class="tag-copyright"><ul class="dummy"><li>Chen, Yi-Cyuan 2014-2023</li></ul></dd>
<dd class="tag-copyright"><ul class="dummy"><li>Chen, Yi-Cyuan 2014-2026</li></ul></dd>
@@ -244,7 +244,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#line95">line 95</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line115">line 115</a>
</li></ul></dd>
@@ -417,7 +417,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#line104">line 104</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line124">line 124</a>
</li></ul></dd>
@@ -590,7 +590,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#line123">line 123</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line143">line 143</a>
</li></ul></dd>
@@ -765,7 +765,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#line113">line 113</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line133">line 133</a>
</li></ul></dd>
@@ -880,7 +880,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#line138">line 138</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line158">line 158</a>
</li></ul></dd>
@@ -1053,7 +1053,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#line86">line 86</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line106">line 106</a>
</li></ul></dd>
@@ -1226,7 +1226,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#line75">line 75</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line95">line 95</a>
</li></ul></dd>
@@ -1401,7 +1401,7 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line146">line 146</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line166">line 166</a>
</li></ul></dd>
@@ -1483,7 +1483,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 27 2023 21:32:04 GMT+0800 (台北標準時間)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time)
</footer>
<script> prettyPrint(); </script>
+2 -2
View File
@@ -214,7 +214,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line852">line 852</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line882">line 882</a>
</li></ul></dd>
@@ -302,7 +302,7 @@ md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 27 2023 21:32:04 GMT+0800 (台北標準時間)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time)
</footer>
<script> prettyPrint(); </script>
+75 -6
View File
@@ -44,16 +44,82 @@
<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>
<p><a href="https://github.com/emn178/js-md5/actions/workflows/ci.yml"><img src="https://github.com/emn178/js-md5/actions/workflows/ci.yml/badge.svg" alt="CI"></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></p>
<p>A simple MD5 hash function for JavaScript supports UTF-8 encoding.</p>
<p>A simple and fast 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>
<ul>
<li><a href="https://raw.github.com/emn178/js-md5/master/build/md5.min.js">Compress</a></li>
<li><a href="https://raw.github.com/emn178/js-md5/master/build/md5.js">Uncompressed build</a></li>
<li><a href="https://raw.github.com/emn178/js-md5/master/build/md5.modern.min.js">Modern</a></li>
<li><a href="https://raw.github.com/emn178/js-md5/master/build/md5.modern.js">Modern uncompressed</a></li>
<li><a href="https://raw.github.com/emn178/js-md5/master/build/md5-lite.min.js">Lite</a></li>
<li><a href="https://raw.github.com/emn178/js-md5/master/build/md5-lite.js">Lite uncompressed</a></li>
<li><a href="https://raw.github.com/emn178/js-md5/master/src/md5.js">Uncompress</a></li>
</ul>
<h3>Builds</h3>
<table>
<thead>
<tr>
<th>Build</th>
<th>Legacy fallbacks</th>
<th>Node acceleration</th>
<th>HMAC</th>
<th>Base64</th>
<th>Deprecated <code>buffer</code></th>
</tr>
</thead>
<tbody>
<tr>
<td><code>md5.js</code> / <code>md5.min.js</code></td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td><code>md5.modern.js</code> / <code>md5.modern.min.js</code></td>
<td>No</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td><code>md5-lite.js</code> / <code>md5-lite.min.js</code></td>
<td>No</td>
<td>No</td>
<td>No</td>
<td>No</td>
<td>No</td>
</tr>
</tbody>
</table>
<p>The modern and lite builds require <code>Array.isArray</code>, <code>ArrayBuffer</code>, typed arrays,
and <code>ArrayBuffer.isView</code>. The lite build keeps the one-shot and streaming MD5
APIs, including <code>hex</code>, <code>array</code>, <code>digest</code>, and <code>arrayBuffer</code> output.</p>
<h2>Benchmark</h2>
<ul>
<li><a href="https://measurethat.net/Benchmarks/Show/29171/0/md5-performance-comparison-v2">Benchmark (measurethat.net) - Short String</a></li>
<li><a href="https://measurethat.net/Benchmarks/Show/29172/0/md5-performance-comparison-long-text-v2">Benchmark (measurethat.net) - Long String</a></li>
<li><a href="https://jsperf.app/jonuhi/6">Benchmark (jsperf.app) - Long String</a></li>
<li><a href="https://measurethat.net/Benchmarks/Show/29173/0/md5-performance-comparison-very-long-text">Benchmark (measurethat.net) - Very Long String</a></li>
<li><a href="https://jsperf.app/jonuhi/8">Benchmark (jsperf.app) - Very Long String</a></li>
<li><a href="https://measurethat.net/Benchmarks/Show/29176/0/md5-performance-comparison-very-long-text-v6">Async Benchmark (measurethat.net)</a></li>
<li><a href="https://jsperf.app/jonuhi/9">Async Benchmark (jsperf.app)</a></li>
</ul>
<ul>
<li>js-md5 is the fastest synchronous MD5 library, but slower than Hash-WASM</li>
</ul>
<ul>
<li><a href="https://github.com/emn178/js-md5/issues/19">File Benchmark - Issue #19</a></li>
<li><a href="https://github.com/emn178/js-md5/issues/42">File Benchmark - Issue #42</a></li>
</ul>
<h2>Installation</h2>
<p>You can also install js-md5 by using Bower.</p>
<pre><code>bower install md5
@@ -81,6 +147,10 @@ hash.hex();
<p>If you use node.js, you should require the module first:</p>
<pre class="prettyprint source lang-JavaScript"><code>var md5 = require('js-md5');
</code></pre>
<h3>TypeScript</h3>
<p>If you use TypeScript, you can import like this:</p>
<pre class="prettyprint source lang-TypeScript"><code>import { md5 } from 'js-md5';
</code></pre>
<h2>RequireJS</h2>
<p>It supports AMD:</p>
<pre class="prettyprint source lang-JavaScript"><code>require(['your/path/md5.js'], function(md5) {
@@ -106,7 +176,6 @@ 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.arrayBuffer(''); // ArrayBuffer
md5.buffer(''); // ArrayBuffer, deprecated, This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
md5.base64(''); // 1B2M2Y8AsgTpgAmY7PhCfg==
// HMAC
@@ -135,7 +204,7 @@ Author: Chen, Yi-Cyuan (emn178@gmail.com)</p></article>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 27 2023 21:32:04 GMT+0800 (台北標準時間)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time)
</footer>
<script> prettyPrint(); </script>
+10 -10
View File
@@ -71,7 +71,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#line207">line 207</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line225">line 225</a>
</li></ul></dd>
@@ -252,7 +252,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#line233">line 233</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line251">line 251</a>
</li></ul></dd>
@@ -457,7 +457,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#line243">line 243</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line261">line 261</a>
</li></ul></dd>
@@ -662,7 +662,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#line264">line 264</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line282">line 282</a>
</li></ul></dd>
@@ -869,7 +869,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#line253">line 253</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line271">line 271</a>
</li></ul></dd>
@@ -1042,7 +1042,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#line280">line 280</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line298">line 298</a>
</li></ul></dd>
@@ -1247,7 +1247,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#line223">line 223</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line241">line 241</a>
</li></ul></dd>
@@ -1452,7 +1452,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#line210">line 210</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line228">line 228</a>
</li></ul></dd>
@@ -1659,7 +1659,7 @@ md5.hmac('key', 'The quick brown fox jumps over the lazy dog');</code></pre>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line289">line 289</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line307">line 307</a>
</li></ul></dd>
@@ -1741,7 +1741,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 27 2023 21:32:04 GMT+0800 (台北標準時間)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time)
</footer>
<script> prettyPrint(); </script>
+10 -10
View File
@@ -93,7 +93,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line317">line 317</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line335">line 335</a>
</li></ul></dd>
@@ -208,7 +208,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#line704">line 704</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line722">line 722</a>
</li></ul></dd>
@@ -330,7 +330,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#line716">line 716</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line734">line 734</a>
</li></ul></dd>
@@ -452,7 +452,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#line751">line 751</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line772">line 772</a>
</li></ul></dd>
@@ -576,7 +576,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#line738">line 738</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line756">line 756</a>
</li></ul></dd>
@@ -698,7 +698,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#line682">line 682</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line700">line 700</a>
</li></ul></dd>
@@ -820,7 +820,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#line637">line 637</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line655">line 655</a>
</li></ul></dd>
@@ -942,7 +942,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#line670">line 670</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line688">line 688</a>
</li></ul></dd>
@@ -1122,7 +1122,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#line345">line 345</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line363">line 363</a>
</li></ul></dd>
@@ -1203,7 +1203,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 27 2023 21:32:04 GMT+0800 (台北標準時間)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time)
</footer>
<script> prettyPrint(); </script>
+72 -42
View File
@@ -30,14 +30,19 @@
* [js-md5]{@link https://github.com/emn178/js-md5}
*
* @namespace md5
* @version 0.8.0
* @version 0.9.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2023
* @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT
*/
(function () {
'use strict';
var FEATURE_LEGACY = true;
var FEATURE_HMAC = true;
var FEATURE_BASE64 = true;
var FEATURE_BUFFER = true;
var INPUT_ERROR = 'input is invalid type';
var FINALIZE_ERROR = 'finalize already called';
var WINDOW = typeof window === 'object';
@@ -46,7 +51,8 @@
WINDOW = false;
}
var WEB_WORKER = !WINDOW &amp;&amp; typeof self === 'object';
var NODE_JS = !root.JS_MD5_NO_NODE_JS &amp;&amp; typeof process === 'object' &amp;&amp; process.versions &amp;&amp; process.versions.node;
/* istanbul ignore next */
var NODE_JS = !root.JS_MD5_NO_NODE_JS &amp;&amp; !WINDOW &amp;&amp; typeof process === 'object' &amp;&amp; process.versions &amp;&amp; process.versions.node;
if (NODE_JS) {
root = global;
} else if (WEB_WORKER) {
@@ -54,12 +60,24 @@
}
var COMMON_JS = !root.JS_MD5_NO_COMMON_JS &amp;&amp; typeof module === 'object' &amp;&amp; module.exports;
var AMD = typeof define === 'function' &amp;&amp; define.amd;
var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER &amp;&amp; typeof ArrayBuffer !== 'undefined';
/* istanbul ignore next */
var ARRAY_BUFFER = FEATURE_LEGACY ?
!root.JS_MD5_NO_ARRAY_BUFFER &amp;&amp; typeof ArrayBuffer !== 'undefined' : true;
var HEX_CHARS = '0123456789abcdef'.split('');
var EXTRA = [128, 32768, 8388608, -2147483648];
var SHIFT = [0, 8, 16, 24];
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64'];
var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
/* istanbul ignore else */
if (FEATURE_BUFFER) {
OUTPUT_TYPES.push('buffer');
}
/* istanbul ignore else */
if (FEATURE_BASE64) {
OUTPUT_TYPES.push('base64');
}
/* istanbul ignore next */
var BASE64_ENCODE_CHAR = FEATURE_BASE64 ?
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('') : null;
var blocks = [], buffer8;
if (ARRAY_BUFFER) {
@@ -69,14 +87,16 @@
}
var isArray = Array.isArray;
if (root.JS_MD5_NO_NODE_JS || !isArray) {
/* istanbul ignore else */
if (FEATURE_LEGACY &amp;&amp; (root.JS_MD5_NO_NODE_JS || !isArray)) {
isArray = function (obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
}
var isView = ArrayBuffer.isView;
if (ARRAY_BUFFER &amp;&amp; (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
/* istanbul ignore else */
if (FEATURE_LEGACY &amp;&amp; ARRAY_BUFFER &amp;&amp; (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
isView = function (obj) {
return typeof obj === 'object' &amp;&amp; obj.buffer &amp;&amp; obj.buffer.constructor === ArrayBuffer;
};
@@ -204,10 +224,8 @@
var nodeWrap = function (method) {
var crypto = require('crypto')
var Buffer = require('buffer').Buffer;
var bufferFrom;
if (Buffer.from &amp;&amp; !root.JS_MD5_NO_BUFFER_FROM) {
bufferFrom = Buffer.from;
} else {
var bufferFrom = Buffer.from;
if (FEATURE_LEGACY &amp;&amp; (root.JS_MD5_NO_BUFFER_FROM || !bufferFrom)) {
bufferFrom = function (message) {
return new Buffer(message);
};
@@ -774,7 +792,10 @@
* @example
* hash.buffer();
*/
Md5.prototype.buffer = Md5.prototype.arrayBuffer;
/* istanbul ignore else */
if (FEATURE_BUFFER) {
Md5.prototype.buffer = Md5.prototype.arrayBuffer;
}
/**
* @method base64
@@ -786,23 +807,26 @@
* @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++];
/* istanbul ignore else */
if (FEATURE_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 | 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;
};
BASE64_ENCODE_CHAR[(v1 &lt;&lt; 4) &amp; 63] +
'==';
return base64Str;
};
}
/**
* HmacMd5 class
@@ -856,23 +880,29 @@
this.inner = true;
this.sharedMemory = sharedMemory;
}
HmacMd5.prototype = new Md5();
/* istanbul ignore else */
if (FEATURE_HMAC) {
HmacMd5.prototype = new Md5();
HmacMd5.prototype.finalize = function () {
Md5.prototype.finalize.call(this);
if (this.inner) {
this.inner = false;
var innerHash = this.array();
Md5.call(this, this.sharedMemory);
this.update(this.oKeyPad);
this.update(innerHash);
HmacMd5.prototype.finalize = function () {
Md5.prototype.finalize.call(this);
}
};
if (this.inner) {
this.inner = false;
var innerHash = this.array();
Md5.call(this, this.sharedMemory);
this.update(this.oKeyPad);
this.update(innerHash);
Md5.prototype.finalize.call(this);
}
};
}
var exports = createMethod();
exports.md5 = exports;
exports.md5.hmac = createHmacMethod();
/* istanbul ignore else */
if (FEATURE_HMAC) {
exports.md5.hmac = createHmacMethod();
}
if (COMMON_JS) {
module.exports = exports;
@@ -918,7 +948,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 27 2023 21:32:04 GMT+0800 (台北標準時間)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time)
</footer>
<script> prettyPrint(); </script>