Compare commits

..
16 Commits
Author SHA1 Message Date
Yi-Cyuan ChenandClaude Opus 5.5 66db5dbd99 ### Fixed
- Incorrect hash for `DataView` input.
- Throws `ArrayBuffer is not defined` in browsers without `ArrayBuffer`.

### Changed
- Multi-byte typed arrays such as `Uint16Array`, `Uint32Array` and `Float32Array` are now hashed by their underlying bytes, the same as Node.js `crypto` and Web Crypto. Previously each element was treated as one byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 13:31:55 +08:00
Yi-Cyuan ChenandClaude Opus 5.5 c2a7870840 ### Changed
- Clarify the benchmark summary in the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:14:32 +08:00
Yi-Cyuan ChenandClaude Opus 5.5 698e7154d2 update README badges
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 17:01:17 +08:00
Yi-Cyuan ChenandClaude Opus 5.5 2bf0dfe852 ### Changed
- Update transitive dev dependencies to fix security advisories (brace-expansion, browserslist, diff, glob, js-yaml, markdown-it, minimatch, serialize-javascript)
- Drop Node.js 16 from CI

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 16:48:47 +08:00
emn178andGitHub 43adee1975 Merge pull request #56 from emn178/dependabot/npm_and_yarn/markdown-it-14.3.3
Bump markdown-it from 14.3.0 to 14.3.3
2026-11-16 16:40:40 +08:00
emn178andGitHub 6fcf6a9639 Merge pull request #55 from emn178/dependabot/npm_and_yarn/multi-581aeff57e
Bump brace-expansion
2026-11-16 16:40:28 +08:00
emn178andGitHub 34f76ca8f2 Merge pull request #53 from emn178/dependabot/npm_and_yarn/multi-c5ebbb4833
Bump js-yaml
2026-11-16 16:40:17 +08:00
emn178andGitHub 5a922fe1d6 Merge pull request #51 from emn178/dependabot/npm_and_yarn/browserslist-4.28.9
Bump browserslist from 4.28.6 to 4.28.9
2026-11-16 16:38:49 +08:00
Yi-Cyuan ChenandClaude Opus 5.5 68b5c32442 ### Fixed
- Unpaired UTF-16 surrogates produce wrong digests and consume the next code unit in the JS path. Unpaired surrogates are now encoded as U+FFFD, matching `TextEncoder` and Node.js `crypto`. #57

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 16:37:59 +08:00
dependabot[bot]andGitHub 56ba32d25d Bump markdown-it from 14.3.0 to 14.3.3
Bumps [markdown-it](https://github.com/markdown-it/markdown-it) from 14.3.0 to 14.3.3.
- [Changelog](https://github.com/markdown-it/markdown-it/blob/14.3.3/CHANGELOG.md)
- [Commits](https://github.com/markdown-it/markdown-it/compare/14.3.0...14.3.3)

---
updated-dependencies:
- dependency-name: markdown-it
  dependency-version: 14.3.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-21 22:55:12 +00:00
dependabot[bot]andGitHub f44a93667b Bump brace-expansion
Bumps  and [brace-expansion](https://github.com/juliangruber/brace-expansion). These dependencies needed to be updated together.

Updates `brace-expansion` from 2.1.2 to 2.1.7
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v2.1.2...v2.1.7)

Updates `brace-expansion` from 5.0.7 to 5.0.12
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v2.1.2...v2.1.7)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 2.1.7
  dependency-type: indirect
- dependency-name: brace-expansion
  dependency-version: 5.0.12
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-12 19:28:48 +00:00
dependabot[bot]andGitHub 906ee91381 Bump js-yaml
Bumps  and [js-yaml](https://github.com/nodeca/js-yaml). These dependencies needed to be updated together.

Updates `js-yaml` from 4.3.0 to 4.3.2
- [Changelog](https://github.com/nodeca/js-yaml/blob/4.3.2/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.3.0...4.3.2)

Updates `js-yaml` from 3.15.0 to 3.15.2
- [Changelog](https://github.com/nodeca/js-yaml/blob/4.3.2/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.3.0...4.3.2)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.3.2
  dependency-type: indirect
- dependency-name: js-yaml
  dependency-version: 3.15.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-13 15:30:19 +00:00
dependabot[bot]andGitHub e55d53a634 Bump browserslist from 4.28.6 to 4.28.9
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.28.6 to 4.28.9.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.28.6...4.28.9)

---
updated-dependencies:
- dependency-name: browserslist
  dependency-version: 4.28.9
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-07 15:37:09 +00:00
Yi-Cyuan Chen ee1c332b60 fixed ci 2026-07-20 14:44:06 +08:00
Yi-Cyuan Chen f6407a6c0c fixed CI tests 2026-07-20 14:23:54 +08:00
Yi-Cyuan Chen 114d18e574 ### Changed
- web worker detection. #44
2026-07-20 11:07:48 +08:00
36 changed files with 1536 additions and 1473 deletions
+8 -4
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: [16.x, 18.x, 20.x, 22.x] node-version: [18.x, 20.x, 22.x, 24.x]
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -27,18 +27,22 @@ jobs:
run: npm ci run: npm ci
- name: Build - name: Build
if: matrix.node-version == '22.x' if: matrix.node-version == '24.x'
run: npm run build run: npm run build
- name: Check generated files
if: matrix.node-version == '24.x'
run: git diff --exit-code -- build
- name: Run tests - name: Run tests
run: npm test run: npm test
- name: Generate coverage report - name: Generate coverage report
if: matrix.node-version == '22.x' if: matrix.node-version == '24.x'
run: npm run coverage run: npm run coverage
- name: Upload to coveralls - name: Upload to coveralls
if: matrix.node-version == '22.x' if: matrix.node-version == '24.x'
uses: coverallsapp/github-action@v2 uses: coverallsapp/github-action@v2
with: with:
file: ./coverage.lcov file: ./coverage.lcov
+1
View File
@@ -2,3 +2,4 @@
/covreporter/ /covreporter/
/.nyc_output/ /.nyc_output/
/coverage/ /coverage/
coverage.lcov
+24
View File
@@ -1,5 +1,29 @@
# Change Log # Change Log
## v0.11.0 / 2026-11-18
### Fixed
- Incorrect hash for `DataView` input.
- Throws `ArrayBuffer is not defined` in browsers without `ArrayBuffer`.
### Changed
- Multi-byte typed arrays such as `Uint16Array`, `Uint32Array` and `Float32Array` are now hashed by their underlying bytes, the same as Node.js `crypto` and Web Crypto. Previously each element was treated as one byte.
## v0.10.0 / 2026-11-16
### Fixed
- Unpaired UTF-16 surrogates produce wrong digests and consume the next code unit in the JS path. Unpaired surrogates are now encoded as U+FFFD, matching `TextEncoder` and Node.js `crypto`. #57
### Changed
- Update transitive dev dependencies to fix security advisories (brace-expansion, browserslist, diff, glob, js-yaml, markdown-it, minimatch, serialize-javascript)
- Drop Node.js 16 from CI
## v0.9.2 / 2026-07-20
### Fixed
- CI test.
## v0.9.1 / 2026-07-20
### Changed
- web worker detection. #44
## v0.9.0 / 2026-07-20 ## v0.9.0 / 2026-07-20
### Added ### Added
- Modern and lite builds generated from the same source. #44 - Modern and lite builds generated from the same source. #44
+4 -3
View File
@@ -1,7 +1,8 @@
# js-md5 # js-md5
[![CI](https://github.com/emn178/js-md5/actions/workflows/ci.yml/badge.svg)](https://github.com/emn178/js-md5/actions/workflows/ci.yml) [![CI](https://github.com/emn178/js-md5/actions/workflows/ci.yml/badge.svg)](https://github.com/emn178/js-md5/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/emn178/js-md5/badge.svg?branch=master)](https://coveralls.io/r/emn178/js-md5?branch=master) [![Coverage Status](https://coveralls.io/repos/emn178/js-md5/badge.svg?branch=master)](https://coveralls.io/r/emn178/js-md5?branch=master)
[![NPM](https://nodei.co/npm/js-md5.png?stars&downloads)](https://nodei.co/npm/js-md5/) [![NPM](https://img.shields.io/npm/v/js-md5)](https://www.npmjs.com/package/js-md5)
[![CDNJS](https://img.shields.io/jsdelivr/npm/hm/js-md5)](https://www.jsdelivr.com/package/npm/js-md5)
A simple and fast MD5 hash function for JavaScript supports UTF-8 encoding. A simple and fast MD5 hash function for JavaScript supports UTF-8 encoding.
@@ -39,7 +40,7 @@ APIs, including `hex`, `array`, `digest`, and `arrayBuffer` output.
- [Async Benchmark (measurethat.net)](https://measurethat.net/Benchmarks/Show/29176/0/md5-performance-comparison-very-long-text-v6) - [Async Benchmark (measurethat.net)](https://measurethat.net/Benchmarks/Show/29176/0/md5-performance-comparison-very-long-text-v6)
- [Async Benchmark (jsperf.app)](https://jsperf.app/jonuhi/9) - [Async Benchmark (jsperf.app)](https://jsperf.app/jonuhi/9)
* js-md5 is the fastest synchronous MD5 library, but slower than Hash-WASM * js-md5 is the fastest for short strings in these benchmarks. For large data, WebAssembly-based libraries (e.g. Hash-WASM) are faster.
- [File Benchmark - Issue #19](https://github.com/emn178/js-md5/issues/19) - [File Benchmark - Issue #19](https://github.com/emn178/js-md5/issues/19)
- [File Benchmark - Issue #42](https://github.com/emn178/js-md5/issues/42) - [File Benchmark - Issue #42](https://github.com/emn178/js-md5/issues/42)
@@ -102,7 +103,7 @@ md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffad
// It also supports UTF-8 encoding // It also supports UTF-8 encoding
md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07 md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07
// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` and other `ArrayBuffer` views (their underlying bytes are hashed)
md5([]); // d41d8cd98f00b204e9800998ecf8427e md5([]); // d41d8cd98f00b204e9800998ecf8427e
md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "js-md5", "name": "js-md5",
"version": "0.9.0", "version": "0.11.0",
"main": ["src/md5.js"], "main": ["src/md5.js"],
"ignore": [ "ignore": [
"tests" "tests"
+20 -8
View File
@@ -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.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -16,7 +16,7 @@
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
/* istanbul ignore next */ /* istanbul ignore next */
var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node; var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) { if (NODE_JS) {
@@ -39,7 +39,7 @@
var isArray = Array.isArray; var isArray = Array.isArray;
var isView = ArrayBuffer.isView; var isView = ArrayBuffer.isView ;
// [message: string, isString: bool] // [message: string, isString: bool]
var formatMessage = function (message) { var formatMessage = function (message) {
@@ -53,10 +53,14 @@
if (message.constructor === ArrayBuffer) { if (message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -172,6 +176,8 @@
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} else if (message.constructor === ArrayBuffer) { } else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (isView(message) && message.constructor !== Buffer) {
message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
} }
} }
if (isArray(message) || isView(message) || if (isArray(message) || isView(message) ||
@@ -227,7 +233,7 @@
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -253,12 +259,18 @@
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} }
+2 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+18 -8
View File
@@ -8,7 +8,7 @@ var md5$1 = {exports: {}};
* [js-md5]{@link https://github.com/emn178/js-md5} * [js-md5]{@link https://github.com/emn178/js-md5}
* *
* @namespace md5 * @namespace md5
* @version 0.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -24,7 +24,7 @@ var md5$1 = {exports: {}};
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
if (WEB_WORKER) { if (WEB_WORKER) {
root = self; root = self;
} }
@@ -42,7 +42,7 @@ var md5$1 = {exports: {}};
var isArray = Array.isArray; var isArray = Array.isArray;
var isView = ArrayBuffer.isView; var isView = ArrayBuffer.isView ;
// [message: string, isString: bool] // [message: string, isString: bool]
var formatMessage = function (message) { var formatMessage = function (message) {
@@ -56,10 +56,14 @@ var md5$1 = {exports: {}};
if (message.constructor === ArrayBuffer) { if (message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -203,7 +207,7 @@ var md5$1 = {exports: {}};
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -229,12 +233,18 @@ var md5$1 = {exports: {}};
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} }
+20 -8
View File
@@ -13,7 +13,7 @@ var md5$1 = {exports: {}};
* [js-md5]{@link https://github.com/emn178/js-md5} * [js-md5]{@link https://github.com/emn178/js-md5}
* *
* @namespace md5 * @namespace md5
* @version 0.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -29,7 +29,7 @@ var md5$1 = {exports: {}};
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
/* istanbul ignore next */ /* istanbul ignore next */
var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node; var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) { if (NODE_JS) {
@@ -51,7 +51,7 @@ var md5$1 = {exports: {}};
var isArray = Array.isArray; var isArray = Array.isArray;
var isView = ArrayBuffer.isView; var isView = ArrayBuffer.isView ;
// [message: string, isString: bool] // [message: string, isString: bool]
var formatMessage = function (message) { var formatMessage = function (message) {
@@ -65,10 +65,14 @@ var md5$1 = {exports: {}};
if (message.constructor === ArrayBuffer) { if (message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -184,6 +188,8 @@ var md5$1 = {exports: {}};
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} else if (message.constructor === ArrayBuffer) { } else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (isView(message) && message.constructor !== Buffer) {
message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
} }
} }
if (isArray(message) || isView(message) || if (isArray(message) || isView(message) ||
@@ -239,7 +245,7 @@ var md5$1 = {exports: {}};
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -265,12 +271,18 @@ var md5$1 = {exports: {}};
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} }
+37 -13
View File
@@ -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.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -16,7 +16,7 @@
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
/* istanbul ignore next */ /* istanbul ignore next */
var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node; var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) { if (NODE_JS) {
@@ -58,7 +58,7 @@
}; };
} }
var isView = ArrayBuffer.isView; var isView = ARRAY_BUFFER ? ArrayBuffer.isView : null;
/* istanbul ignore else */ /* istanbul ignore else */
if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) { if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
isView = function (obj) { isView = function (obj) {
@@ -78,10 +78,14 @@
if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!ARRAY_BUFFER || !isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -202,6 +206,8 @@
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} else if (message.constructor === ArrayBuffer) { } else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (ARRAY_BUFFER && isView(message) && message.constructor !== Buffer) {
message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
} }
} }
if (isArray(message) || isView(message) || if (isArray(message) || isView(message) ||
@@ -369,7 +375,7 @@
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -395,12 +401,18 @@
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} else { } else {
@@ -415,12 +427,18 @@
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else {
// unpaired surrogate: U+FFFD
blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3];
blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3];
blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3];
} }
} }
} }
@@ -803,7 +821,7 @@
var i, result = formatMessage(key); var i, result = formatMessage(key);
key = result[0]; key = result[0];
if (result[1]) { if (result[1]) {
var bytes = [], length = key.length, index = 0, code; var bytes = [], length = key.length, index = 0, code, code2;
for (i = 0; i < length; ++i) { for (i = 0; i < length; ++i) {
code = key.charCodeAt(i); code = key.charCodeAt(i);
if (code < 0x80) { if (code < 0x80) {
@@ -815,12 +833,18 @@
bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0xe0 | (code >>> 12));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else { } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); ++i;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0xf0 | (code >>> 18));
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else {
// unpaired surrogate: U+FFFD
bytes[index++] = 0xef;
bytes[index++] = 0xbf;
bytes[index++] = 0xbd;
} }
} }
key = bytes; key = bytes;
+2 -2
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+35 -13
View File
@@ -8,7 +8,7 @@ var md5$1 = {exports: {}};
* [js-md5]{@link https://github.com/emn178/js-md5} * [js-md5]{@link https://github.com/emn178/js-md5}
* *
* @namespace md5 * @namespace md5
* @version 0.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -24,7 +24,7 @@ var md5$1 = {exports: {}};
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
if (WEB_WORKER) { if (WEB_WORKER) {
root = self; root = self;
} }
@@ -61,7 +61,7 @@ var md5$1 = {exports: {}};
}; };
} }
var isView = ArrayBuffer.isView; var isView = ARRAY_BUFFER ? ArrayBuffer.isView : null;
/* istanbul ignore else */ /* istanbul ignore else */
if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) { if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
isView = function (obj) { isView = function (obj) {
@@ -81,10 +81,14 @@ var md5$1 = {exports: {}};
if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!ARRAY_BUFFER || !isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -340,7 +344,7 @@ var md5$1 = {exports: {}};
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -366,12 +370,18 @@ var md5$1 = {exports: {}};
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} else { } else {
@@ -386,12 +396,18 @@ var md5$1 = {exports: {}};
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else {
// unpaired surrogate: U+FFFD
blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3];
blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3];
blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3];
} }
} }
} }
@@ -774,7 +790,7 @@ var md5$1 = {exports: {}};
var i, result = formatMessage(key); var i, result = formatMessage(key);
key = result[0]; key = result[0];
if (result[1]) { if (result[1]) {
var bytes = [], length = key.length, index = 0, code; var bytes = [], length = key.length, index = 0, code, code2;
for (i = 0; i < length; ++i) { for (i = 0; i < length; ++i) {
code = key.charCodeAt(i); code = key.charCodeAt(i);
if (code < 0x80) { if (code < 0x80) {
@@ -786,12 +802,18 @@ var md5$1 = {exports: {}};
bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0xe0 | (code >>> 12));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else { } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); ++i;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0xf0 | (code >>> 18));
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else {
// unpaired surrogate: U+FFFD
bytes[index++] = 0xef;
bytes[index++] = 0xbf;
bytes[index++] = 0xbd;
} }
} }
key = bytes; key = bytes;
+29 -11
View File
@@ -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.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -16,7 +16,7 @@
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
/* istanbul ignore next */ /* istanbul ignore next */
var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node; var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) { if (NODE_JS) {
@@ -49,7 +49,7 @@
var isArray = Array.isArray; var isArray = Array.isArray;
var isView = ArrayBuffer.isView; var isView = ArrayBuffer.isView ;
// [message: string, isString: bool] // [message: string, isString: bool]
var formatMessage = function (message) { var formatMessage = function (message) {
@@ -63,10 +63,14 @@
if (message.constructor === ArrayBuffer) { if (message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -182,6 +186,8 @@
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} else if (message.constructor === ArrayBuffer) { } else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (isView(message) && message.constructor !== Buffer) {
message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
} }
} }
if (isArray(message) || isView(message) || if (isArray(message) || isView(message) ||
@@ -347,7 +353,7 @@
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -373,12 +379,18 @@
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} }
@@ -757,7 +769,7 @@
var i, result = formatMessage(key); var i, result = formatMessage(key);
key = result[0]; key = result[0];
if (result[1]) { if (result[1]) {
var bytes = [], length = key.length, index = 0, code; var bytes = [], length = key.length, index = 0, code, code2;
for (i = 0; i < length; ++i) { for (i = 0; i < length; ++i) {
code = key.charCodeAt(i); code = key.charCodeAt(i);
if (code < 0x80) { if (code < 0x80) {
@@ -769,12 +781,18 @@
bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0xe0 | (code >>> 12));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else { } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); ++i;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0xf0 | (code >>> 18));
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else {
// unpaired surrogate: U+FFFD
bytes[index++] = 0xef;
bytes[index++] = 0xbf;
bytes[index++] = 0xbd;
} }
} }
key = bytes; key = bytes;
+2 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+27 -11
View File
@@ -8,7 +8,7 @@ var md5$1 = {exports: {}};
* [js-md5]{@link https://github.com/emn178/js-md5} * [js-md5]{@link https://github.com/emn178/js-md5}
* *
* @namespace md5 * @namespace md5
* @version 0.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -24,7 +24,7 @@ var md5$1 = {exports: {}};
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
if (WEB_WORKER) { if (WEB_WORKER) {
root = self; root = self;
} }
@@ -52,7 +52,7 @@ var md5$1 = {exports: {}};
var isArray = Array.isArray; var isArray = Array.isArray;
var isView = ArrayBuffer.isView; var isView = ArrayBuffer.isView ;
// [message: string, isString: bool] // [message: string, isString: bool]
var formatMessage = function (message) { var formatMessage = function (message) {
@@ -66,10 +66,14 @@ var md5$1 = {exports: {}};
if (message.constructor === ArrayBuffer) { if (message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -323,7 +327,7 @@ var md5$1 = {exports: {}};
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -349,12 +353,18 @@ var md5$1 = {exports: {}};
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} }
@@ -733,7 +743,7 @@ var md5$1 = {exports: {}};
var i, result = formatMessage(key); var i, result = formatMessage(key);
key = result[0]; key = result[0];
if (result[1]) { if (result[1]) {
var bytes = [], length = key.length, index = 0, code; var bytes = [], length = key.length, index = 0, code, code2;
for (i = 0; i < length; ++i) { for (i = 0; i < length; ++i) {
code = key.charCodeAt(i); code = key.charCodeAt(i);
if (code < 0x80) { if (code < 0x80) {
@@ -745,12 +755,18 @@ var md5$1 = {exports: {}};
bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0xe0 | (code >>> 12));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else { } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); ++i;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0xf0 | (code >>> 18));
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else {
// unpaired surrogate: U+FFFD
bytes[index++] = 0xef;
bytes[index++] = 0xbf;
bytes[index++] = 0xbd;
} }
} }
key = bytes; key = bytes;
+29 -11
View File
@@ -13,7 +13,7 @@ var md5$1 = {exports: {}};
* [js-md5]{@link https://github.com/emn178/js-md5} * [js-md5]{@link https://github.com/emn178/js-md5}
* *
* @namespace md5 * @namespace md5
* @version 0.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -29,7 +29,7 @@ var md5$1 = {exports: {}};
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
/* istanbul ignore next */ /* istanbul ignore next */
var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node; var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) { if (NODE_JS) {
@@ -61,7 +61,7 @@ var md5$1 = {exports: {}};
var isArray = Array.isArray; var isArray = Array.isArray;
var isView = ArrayBuffer.isView; var isView = ArrayBuffer.isView ;
// [message: string, isString: bool] // [message: string, isString: bool]
var formatMessage = function (message) { var formatMessage = function (message) {
@@ -75,10 +75,14 @@ var md5$1 = {exports: {}};
if (message.constructor === ArrayBuffer) { if (message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -194,6 +198,8 @@ var md5$1 = {exports: {}};
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} else if (message.constructor === ArrayBuffer) { } else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (isView(message) && message.constructor !== Buffer) {
message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
} }
} }
if (isArray(message) || isView(message) || if (isArray(message) || isView(message) ||
@@ -359,7 +365,7 @@ var md5$1 = {exports: {}};
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -385,12 +391,18 @@ var md5$1 = {exports: {}};
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} }
@@ -769,7 +781,7 @@ var md5$1 = {exports: {}};
var i, result = formatMessage(key); var i, result = formatMessage(key);
key = result[0]; key = result[0];
if (result[1]) { if (result[1]) {
var bytes = [], length = key.length, index = 0, code; var bytes = [], length = key.length, index = 0, code, code2;
for (i = 0; i < length; ++i) { for (i = 0; i < length; ++i) {
code = key.charCodeAt(i); code = key.charCodeAt(i);
if (code < 0x80) { if (code < 0x80) {
@@ -781,12 +793,18 @@ var md5$1 = {exports: {}};
bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0xe0 | (code >>> 12));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else { } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); ++i;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0xf0 | (code >>> 18));
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else {
// unpaired surrogate: U+FFFD
bytes[index++] = 0xef;
bytes[index++] = 0xbf;
bytes[index++] = 0xbd;
} }
} }
key = bytes; key = bytes;
+37 -13
View File
@@ -13,7 +13,7 @@ var md5$1 = {exports: {}};
* [js-md5]{@link https://github.com/emn178/js-md5} * [js-md5]{@link https://github.com/emn178/js-md5}
* *
* @namespace md5 * @namespace md5
* @version 0.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -29,7 +29,7 @@ var md5$1 = {exports: {}};
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
/* istanbul ignore next */ /* istanbul ignore next */
var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node; var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) { if (NODE_JS) {
@@ -70,7 +70,7 @@ var md5$1 = {exports: {}};
}; };
} }
var isView = ArrayBuffer.isView; var isView = ARRAY_BUFFER ? ArrayBuffer.isView : null;
/* istanbul ignore else */ /* istanbul ignore else */
if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) { if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
isView = function (obj) { isView = function (obj) {
@@ -90,10 +90,14 @@ var md5$1 = {exports: {}};
if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!ARRAY_BUFFER || !isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
}; };
/** /**
@@ -214,6 +218,8 @@ var md5$1 = {exports: {}};
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} else if (message.constructor === ArrayBuffer) { } else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (ARRAY_BUFFER && isView(message) && message.constructor !== Buffer) {
message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
} }
} }
if (isArray(message) || isView(message) || if (isArray(message) || isView(message) ||
@@ -381,7 +387,7 @@ var md5$1 = {exports: {}};
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -407,12 +413,18 @@ var md5$1 = {exports: {}};
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} else { } else {
@@ -427,12 +439,18 @@ var md5$1 = {exports: {}};
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else {
// unpaired surrogate: U+FFFD
blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3];
blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3];
blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3];
} }
} }
} }
@@ -815,7 +833,7 @@ var md5$1 = {exports: {}};
var i, result = formatMessage(key); var i, result = formatMessage(key);
key = result[0]; key = result[0];
if (result[1]) { if (result[1]) {
var bytes = [], length = key.length, index = 0, code; var bytes = [], length = key.length, index = 0, code, code2;
for (i = 0; i < length; ++i) { for (i = 0; i < length; ++i) {
code = key.charCodeAt(i); code = key.charCodeAt(i);
if (code < 0x80) { if (code < 0x80) {
@@ -827,12 +845,18 @@ var md5$1 = {exports: {}};
bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0xe0 | (code >>> 12));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else { } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); ++i;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0xf0 | (code >>> 18));
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else {
// unpaired surrogate: U+FFFD
bytes[index++] = 0xef;
bytes[index++] = 0xbf;
bytes[index++] = 0xbd;
} }
} }
key = bytes; key = bytes;
+10 -10
View File
@@ -93,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#line803">line 803</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line821">line 821</a>
</li></ul></dd> </li></ul></dd>
@@ -224,7 +224,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#line722">line 722</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line740">line 740</a>
</li></ul></dd> </li></ul></dd>
@@ -351,7 +351,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#line734">line 734</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line752">line 752</a>
</li></ul></dd> </li></ul></dd>
@@ -478,7 +478,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#line772">line 772</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line790">line 790</a>
</li></ul></dd> </li></ul></dd>
@@ -607,7 +607,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#line756">line 756</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line774">line 774</a>
</li></ul></dd> </li></ul></dd>
@@ -734,7 +734,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#line700">line 700</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line718">line 718</a>
</li></ul></dd> </li></ul></dd>
@@ -861,7 +861,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#line655">line 655</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line673">line 673</a>
</li></ul></dd> </li></ul></dd>
@@ -988,7 +988,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#line688">line 688</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line706">line 706</a>
</li></ul></dd> </li></ul></dd>
@@ -1173,7 +1173,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#line363">line 363</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line369">line 369</a>
</li></ul></dd> </li></ul></dd>
@@ -1254,7 +1254,7 @@
<br class="clear"> <br class="clear">
<footer> <footer>
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) Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a>
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>
+10 -10
View File
@@ -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.9.0</li></ul></dd> <dd class="tag-version"><ul class="dummy"><li>0.11.0</li></ul></dd>
@@ -244,7 +244,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#line115">line 115</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line119">line 119</a>
</li></ul></dd> </li></ul></dd>
@@ -417,7 +417,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#line124">line 124</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line128">line 128</a>
</li></ul></dd> </li></ul></dd>
@@ -590,7 +590,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#line143">line 143</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line147">line 147</a>
</li></ul></dd> </li></ul></dd>
@@ -765,7 +765,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#line133">line 133</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line137">line 137</a>
</li></ul></dd> </li></ul></dd>
@@ -880,7 +880,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#line158">line 158</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line162">line 162</a>
</li></ul></dd> </li></ul></dd>
@@ -1053,7 +1053,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#line106">line 106</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line110">line 110</a>
</li></ul></dd> </li></ul></dd>
@@ -1226,7 +1226,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#line95">line 95</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line99">line 99</a>
</li></ul></dd> </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> <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#line166">line 166</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line170">line 170</a>
</li></ul></dd> </li></ul></dd>
@@ -1483,7 +1483,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time) Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a>
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>
+2 -2
View File
@@ -214,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#line882">line 882</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line906">line 906</a>
</li></ul></dd> </li></ul></dd>
@@ -302,7 +302,7 @@ md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
<br class="clear"> <br class="clear">
<footer> <footer>
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) Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a>
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>
+6 -5
View File
@@ -45,8 +45,9 @@
<section> <section>
<article><h1>js-md5</h1> <article><h1>js-md5</h1>
<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> <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://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>
<a href="https://nodei.co/npm/js-md5/"><img src="https://nodei.co/npm/js-md5.png?stars&amp;downloads" alt="NPM"></a></p> <a href="https://www.npmjs.com/package/js-md5"><img src="https://img.shields.io/npm/v/js-md5" alt="NPM"></a>
<a href="https://www.jsdelivr.com/package/npm/js-md5"><img src="https://img.shields.io/jsdelivr/npm/hm/js-md5" alt="CDNJS"></a></p>
<p>A simple and fast 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> <h2>Demo</h2>
<p><a href="http://emn178.github.io/online-tools/md5.html">MD5 Online</a><br> <p><a href="http://emn178.github.io/online-tools/md5.html">MD5 Online</a><br>
@@ -114,7 +115,7 @@ APIs, including <code>hex</code>, <code>array</code>, <code>digest</code>, and <
<li><a href="https://jsperf.app/jonuhi/9">Async Benchmark (jsperf.app)</a></li> <li><a href="https://jsperf.app/jonuhi/9">Async Benchmark (jsperf.app)</a></li>
</ul> </ul>
<ul> <ul>
<li>js-md5 is the fastest synchronous MD5 library, but slower than Hash-WASM</li> <li>js-md5 is the fastest for short strings in these benchmarks. For large data, WebAssembly-based libraries (e.g. Hash-WASM) are faster.</li>
</ul> </ul>
<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/19">File Benchmark - Issue #19</a></li>
@@ -166,7 +167,7 @@ md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffad
// It also supports UTF-8 encoding // It also supports UTF-8 encoding
md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07 md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07
// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` and other `ArrayBuffer` views (their underlying bytes are hashed)
md5([]); // d41d8cd98f00b204e9800998ecf8427e md5([]); // d41d8cd98f00b204e9800998ecf8427e
md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e
@@ -204,7 +205,7 @@ Author: Chen, Yi-Cyuan (emn178@gmail.com)</p></article>
<br class="clear"> <br class="clear">
<footer> <footer>
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) Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a>
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>
+10 -10
View File
@@ -71,7 +71,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#line225">line 225</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line231">line 231</a>
</li></ul></dd> </li></ul></dd>
@@ -252,7 +252,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#line251">line 251</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line257">line 257</a>
</li></ul></dd> </li></ul></dd>
@@ -457,7 +457,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#line261">line 261</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line267">line 267</a>
</li></ul></dd> </li></ul></dd>
@@ -662,7 +662,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#line282">line 282</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line288">line 288</a>
</li></ul></dd> </li></ul></dd>
@@ -869,7 +869,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#line271">line 271</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line277">line 277</a>
</li></ul></dd> </li></ul></dd>
@@ -1042,7 +1042,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#line298">line 298</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line304">line 304</a>
</li></ul></dd> </li></ul></dd>
@@ -1247,7 +1247,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#line241">line 241</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line247">line 247</a>
</li></ul></dd> </li></ul></dd>
@@ -1452,7 +1452,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#line228">line 228</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line234">line 234</a>
</li></ul></dd> </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> <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#line307">line 307</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line313">line 313</a>
</li></ul></dd> </li></ul></dd>
@@ -1741,7 +1741,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
<br class="clear"> <br class="clear">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Jul 20 2026 10:19:21 GMT+0800 (Taipei Standard Time) Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a>
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>
+10 -10
View File
@@ -93,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#line335">line 335</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line341">line 341</a>
</li></ul></dd> </li></ul></dd>
@@ -208,7 +208,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#line722">line 722</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line740">line 740</a>
</li></ul></dd> </li></ul></dd>
@@ -330,7 +330,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#line734">line 734</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line752">line 752</a>
</li></ul></dd> </li></ul></dd>
@@ -452,7 +452,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#line772">line 772</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line790">line 790</a>
</li></ul></dd> </li></ul></dd>
@@ -576,7 +576,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#line756">line 756</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line774">line 774</a>
</li></ul></dd> </li></ul></dd>
@@ -698,7 +698,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#line700">line 700</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line718">line 718</a>
</li></ul></dd> </li></ul></dd>
@@ -820,7 +820,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#line655">line 655</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line673">line 673</a>
</li></ul></dd> </li></ul></dd>
@@ -942,7 +942,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#line688">line 688</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line706">line 706</a>
</li></ul></dd> </li></ul></dd>
@@ -1122,7 +1122,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#line363">line 363</a> <a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line369">line 369</a>
</li></ul></dd> </li></ul></dd>
@@ -1203,7 +1203,7 @@
<br class="clear"> <br class="clear">
<footer> <footer>
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) Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a>
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>
+39 -15
View File
@@ -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.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -50,7 +50,7 @@
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW &amp;&amp; typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' &amp;&amp; typeof self !== 'undefined' &amp;&amp; self instanceof WorkerGlobalScope;
/* istanbul ignore next */ /* 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; 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) { if (NODE_JS) {
@@ -94,7 +94,7 @@
}; };
} }
var isView = ArrayBuffer.isView; var isView = ARRAY_BUFFER ? ArrayBuffer.isView : null;
/* istanbul ignore else */ /* istanbul ignore else */
if (FEATURE_LEGACY &amp;&amp; ARRAY_BUFFER &amp;&amp; (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) { if (FEATURE_LEGACY &amp;&amp; ARRAY_BUFFER &amp;&amp; (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
isView = function (obj) { isView = function (obj) {
@@ -114,11 +114,15 @@
if (ARRAY_BUFFER &amp;&amp; message.constructor === ArrayBuffer) { if (ARRAY_BUFFER &amp;&amp; message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) &amp;&amp; !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!ARRAY_BUFFER || !isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
} return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
};
/** /**
* @method hex * @method hex
@@ -238,6 +242,8 @@
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} else if (message.constructor === ArrayBuffer) { } else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (ARRAY_BUFFER &amp;&amp; isView(message) &amp;&amp; message.constructor !== Buffer) {
message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
} }
} }
if (isArray(message) || isView(message) || if (isArray(message) || isView(message) ||
@@ -405,7 +411,7 @@
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index &lt; length) { while (index &lt; length) {
@@ -431,12 +437,18 @@
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) &amp; 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) &amp; 0x3f);
buffer8[i++] = 0x80 | (code &amp; 0x3f); buffer8[i++] = 0x80 | (code &amp; 0x3f);
} else { } else if (code &lt; 0xdc00 &amp;&amp; (code2 = message.charCodeAt(index + 1)) >= 0xdc00 &amp;&amp; code2 &lt; 0xe000) {
code = 0x10000 + (((code &amp; 0x3ff) &lt;&lt; 10) | (message.charCodeAt(++index) &amp; 0x3ff)); ++index;
code = 0x10000 + (((code &amp; 0x3ff) &lt;&lt; 10) | (code2 &amp; 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) &amp; 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) &amp; 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) &amp; 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) &amp; 0x3f);
buffer8[i++] = 0x80 | (code &amp; 0x3f); buffer8[i++] = 0x80 | (code &amp; 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} else { } else {
@@ -451,12 +463,18 @@
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) &lt;&lt; SHIFT[i++ &amp; 3]; blocks[i >>> 2] |= (0xe0 | (code >>> 12)) &lt;&lt; SHIFT[i++ &amp; 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3];
blocks[i >>> 2] |= (0x80 | (code &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3]; blocks[i >>> 2] |= (0x80 | (code &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3];
} else { } else if (code &lt; 0xdc00 &amp;&amp; (code2 = message.charCodeAt(index + 1)) >= 0xdc00 &amp;&amp; code2 &lt; 0xe000) {
code = 0x10000 + (((code &amp; 0x3ff) &lt;&lt; 10) | (message.charCodeAt(++index) &amp; 0x3ff)); ++index;
code = 0x10000 + (((code &amp; 0x3ff) &lt;&lt; 10) | (code2 &amp; 0x3ff));
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) &lt;&lt; SHIFT[i++ &amp; 3]; blocks[i >>> 2] |= (0xf0 | (code >>> 18)) &lt;&lt; SHIFT[i++ &amp; 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 12) &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3];
blocks[i >>> 2] |= (0x80 | (code &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3]; blocks[i >>> 2] |= (0x80 | (code &amp; 0x3f)) &lt;&lt; SHIFT[i++ &amp; 3];
} else {
// unpaired surrogate: U+FFFD
blocks[i >>> 2] |= 0xef &lt;&lt; SHIFT[i++ &amp; 3];
blocks[i >>> 2] |= 0xbf &lt;&lt; SHIFT[i++ &amp; 3];
blocks[i >>> 2] |= 0xbd &lt;&lt; SHIFT[i++ &amp; 3];
} }
} }
} }
@@ -839,7 +857,7 @@
var i, result = formatMessage(key); var i, result = formatMessage(key);
key = result[0]; key = result[0];
if (result[1]) { if (result[1]) {
var bytes = [], length = key.length, index = 0, code; var bytes = [], length = key.length, index = 0, code, code2;
for (i = 0; i &lt; length; ++i) { for (i = 0; i &lt; length; ++i) {
code = key.charCodeAt(i); code = key.charCodeAt(i);
if (code &lt; 0x80) { if (code &lt; 0x80) {
@@ -851,12 +869,18 @@
bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0xe0 | (code >>> 12));
bytes[index++] = (0x80 | ((code >>> 6) &amp; 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) &amp; 0x3f));
bytes[index++] = (0x80 | (code &amp; 0x3f)); bytes[index++] = (0x80 | (code &amp; 0x3f));
} else { } else if (code &lt; 0xdc00 &amp;&amp; (code2 = key.charCodeAt(i + 1)) >= 0xdc00 &amp;&amp; code2 &lt; 0xe000) {
code = 0x10000 + (((code &amp; 0x3ff) &lt;&lt; 10) | (key.charCodeAt(++i) &amp; 0x3ff)); ++i;
code = 0x10000 + (((code &amp; 0x3ff) &lt;&lt; 10) | (code2 &amp; 0x3ff));
bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0xf0 | (code >>> 18));
bytes[index++] = (0x80 | ((code >>> 12) &amp; 0x3f)); bytes[index++] = (0x80 | ((code >>> 12) &amp; 0x3f));
bytes[index++] = (0x80 | ((code >>> 6) &amp; 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) &amp; 0x3f));
bytes[index++] = (0x80 | (code &amp; 0x3f)); bytes[index++] = (0x80 | (code &amp; 0x3f));
} else {
// unpaired surrogate: U+FFFD
bytes[index++] = 0xef;
bytes[index++] = 0xbf;
bytes[index++] = 0xbd;
} }
} }
key = bytes; key = bytes;
@@ -948,7 +972,7 @@
<br class="clear"> <br class="clear">
<footer> <footer>
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) Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a>
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>
Vendored
+1 -1
View File
@@ -1,4 +1,4 @@
type Message = string | number[] | ArrayBuffer | Uint8Array; type Message = string | number[] | ArrayBuffer | ArrayBufferView;
interface Hasher { interface Hasher {
/** /**
+7
View File
@@ -0,0 +1,7 @@
{
"templates": {
"default": {
"includeDate": false
}
}
}
+1053 -1267
View File
File diff suppressed because it is too large Load Diff
+14 -9
View File
@@ -1,6 +1,6 @@
{ {
"name": "js-md5", "name": "js-md5",
"version": "0.9.0", "version": "0.11.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",
"module": "build/md5.mjs", "module": "build/md5.mjs",
@@ -35,23 +35,22 @@
}, },
"types": "./index.d.ts", "types": "./index.d.ts",
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^28.0.5", "@rollup/plugin-commonjs": "^29.0.3",
"@rollup/plugin-terser": "^1.0.0", "@rollup/plugin-terser": "^1.0.0",
"expect.js": "~0.3.1", "expect.js": "~0.3.1",
"jsdoc": "~4.0.2", "jsdoc": "~4.0.2",
"mocha": "~10.2.0", "mocha": "^11.7.6",
"nyc": "^15.1.0", "nyc": "^18.0.0",
"requirejs": "^2.1.22", "requirejs": "^2.1.22",
"rollup": "^4.43.0", "rollup": "^4.43.0",
"tiny-worker": "^2.3.0" "tiny-worker": "^2.3.0"
}, },
"scripts": { "scripts": {
"test": "npm run compress && nyc mocha tests/node-test.js && node tests/build-test.js && node tests/esm-test.mjs", "test": "nyc mocha tests/node-test.js && node tests/build-test.js && node tests/esm-test.mjs",
"report": "nyc --reporter=html --reporter=text mocha tests/node-test.js", "report": "nyc --reporter=html --reporter=text mocha tests/node-test.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls", "coverage": "nyc report --reporter=text-lcov > coverage.lcov",
"doc": "rm -rf doc;jsdoc src README.md -d doc", "doc": "rm -rf doc && jsdoc -c jsdoc.json src README.md -d doc",
"compress": "rollup -c", "build": "rollup -c && npm run doc"
"build": "npm run-script compress;npm run-script doc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -78,5 +77,11 @@
"browser": { "browser": {
"crypto": false, "crypto": false,
"buffer": false "buffer": false
},
"overrides": {
"diff": "^8.0.3",
"glob": "^14.0.2",
"minimatch": "^11.0.1",
"serialize-javascript": "^7.1.3"
} }
} }
+38 -14
View File
@@ -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.9.0 * @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com] * @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2026 * @copyright Chen, Yi-Cyuan 2014-2026
* @license MIT * @license MIT
@@ -22,7 +22,7 @@
if (root.JS_MD5_NO_WINDOW) { if (root.JS_MD5_NO_WINDOW) {
WINDOW = false; WINDOW = false;
} }
var WEB_WORKER = !WINDOW && typeof self === 'object'; var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
/* istanbul ignore next */ /* istanbul ignore next */
var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node; var NODE_JS = !root.JS_MD5_NO_NODE_JS && !WINDOW && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) { if (NODE_JS) {
@@ -66,7 +66,7 @@
}; };
} }
var isView = ArrayBuffer.isView; var isView = ARRAY_BUFFER ? ArrayBuffer.isView : null;
/* istanbul ignore else */ /* istanbul ignore else */
if (FEATURE_LEGACY && ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) { if (FEATURE_LEGACY && ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
isView = function (obj) { isView = function (obj) {
@@ -86,11 +86,15 @@
if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
return [new Uint8Array(message), false]; return [new Uint8Array(message), false];
} }
if (!isArray(message) && !isView(message)) { if (isArray(message)) {
return [message, false];
}
if (!ARRAY_BUFFER || !isView(message)) {
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} }
return [message, false]; // read the underlying bytes of any view (DataView, Uint16Array, ...)
} return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];
};
/** /**
* @method hex * @method hex
@@ -210,6 +214,8 @@
throw new Error(INPUT_ERROR); throw new Error(INPUT_ERROR);
} else if (message.constructor === ArrayBuffer) { } else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message); message = new Uint8Array(message);
} else if (ARRAY_BUFFER && isView(message) && message.constructor !== Buffer) {
message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
} }
} }
if (isArray(message) || isView(message) || if (isArray(message) || isView(message) ||
@@ -377,7 +383,7 @@
var result = formatMessage(message); var result = formatMessage(message);
message = result[0]; message = result[0];
var isString = result[1]; var isString = result[1];
var code, index = 0, i, length = message.length, blocks = this.blocks; var code, code2, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8; var buffer8 = this.buffer8;
while (index < length) { while (index < length) {
@@ -403,12 +409,18 @@
buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0xe0 | (code >>> 12);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0xf0 | (code >>> 18);
buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f);
} else {
// unpaired surrogate: U+FFFD
buffer8[i++] = 0xef;
buffer8[i++] = 0xbf;
buffer8[i++] = 0xbd;
} }
} }
} else { } else {
@@ -423,12 +435,18 @@
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else { } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); ++index;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else {
// unpaired surrogate: U+FFFD
blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3];
blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3];
blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3];
} }
} }
} }
@@ -811,7 +829,7 @@
var i, result = formatMessage(key); var i, result = formatMessage(key);
key = result[0]; key = result[0];
if (result[1]) { if (result[1]) {
var bytes = [], length = key.length, index = 0, code; var bytes = [], length = key.length, index = 0, code, code2;
for (i = 0; i < length; ++i) { for (i = 0; i < length; ++i) {
code = key.charCodeAt(i); code = key.charCodeAt(i);
if (code < 0x80) { if (code < 0x80) {
@@ -823,12 +841,18 @@
bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0xe0 | (code >>> 12));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else { } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) {
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); ++i;
code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));
bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0xf0 | (code >>> 18));
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f));
} else {
// unpaired surrogate: U+FFFD
bytes[index++] = 0xef;
bytes[index++] = 0xbf;
bytes[index++] = 0xbd;
} }
} }
key = bytes; key = bytes;
+10
View File
@@ -57,4 +57,14 @@ expect(browserLite.base64).to.be(undefined);
expect(browserLite.buffer).to.be(undefined); expect(browserLite.buffer).to.be(undefined);
expect(browserLite.hmac).to.be(undefined); expect(browserLite.hmac).to.be(undefined);
// legacy builds load in browsers without ArrayBuffer
['build/md5.js', 'build/md5.min.js'].forEach(function (file) {
var context = vm.createContext({});
vm.runInContext('var window = this; delete ArrayBuffer; delete Uint8Array; delete Uint32Array; delete DataView;', context);
vm.runInContext(fs.readFileSync(file, 'utf8'), context);
expect(context.md5('abc')).to.be(EXPECTED_MD5);
expect(context.md5.create().update('a').update([98, 99]).hex()).to.be(EXPECTED_MD5);
expect(context.md5.hmac('key', 'abc')).to.be(EXPECTED_HMAC);
});
console.log('Build variants: PASS'); console.log('Build variants: PASS');
+4
View File
@@ -45,6 +45,10 @@
'05fe3b294344f4e93c811e10f9825a38': ['中文', '中文'], '05fe3b294344f4e93c811e10f9825a38': ['中文', '中文'],
'c1bc6df91f38e6332b8562324005103d': ['aécio', 'aécio'], 'c1bc6df91f38e6332b8562324005103d': ['aécio', 'aécio'],
'14eef78533c35078177d11fb4593a19e': ['𠜎', '𠜎'] '14eef78533c35078177d11fb4593a19e': ['𠜎', '𠜎']
},
'UTF8 unpaired surrogates': {
'2ef4c67742d4f436cbdfdbad133659af': ['\ud800', 'a\ud83db'],
'f537b6e97a3e8b23a9e87a29fb5c4173': ['a\udc00b', '\ud83d\ude00\udfff']
} }
} }
}; };
+2 -1
View File
@@ -103,12 +103,13 @@ require('./worker-test.js');
delete require.cache[require.resolve('./worker-test.js')]; delete require.cache[require.resolve('./worker-test.js')];
// cover webworker // cover webworker
WorkerGlobalScope = function () { }
JS_MD5_NO_WINDOW = true; JS_MD5_NO_WINDOW = true;
JS_MD5_NO_NODE_JS = true; JS_MD5_NO_NODE_JS = true;
WORKER = './worker.js'; WORKER = './worker.js';
SOURCE = '../src/md5.js'; SOURCE = '../src/md5.js';
window = global; window = global;
self = global; self = new WorkerGlobalScope();
Worker = function (file) { Worker = function (file) {
require(file); require(file);
+15
View File
@@ -27,6 +27,16 @@
'edce615b179e6e29be23145b77ebbd61': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一', 'edce615b179e6e29be23145b77ebbd61': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
'ad36c9ab669a0ba9ce46d3ce9134de34': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。' 'ad36c9ab669a0ba9ce46d3ce9134de34': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
}, },
'UTF8 unpaired surrogates': {
'9b759040321a408a5c7768b4511287a6': '\ud800',
'e240e5e976deb550ea69ec12f01d19ea': '\udc00x',
'ff6405018d5ab2642e35fdba389b7c51': 'a\ud83db',
'ef175e9b596d296034dda690087252f8': 'a\udc00',
'2e906629739ba554e03c1201e05b94f2': '\ud83d\ud83d\ude00',
'468a7f02af0808ae39ef3e3629ae048c': '\ud83d\ude00\udfff',
'6785af8cb378bd9950085c5d6375f9ad': Array(57).join('0') + '\ud800',
'a20fb4cd303a71aa61dd524e8fc525ef': Array(64).join('0') + '\ud800b'
},
'special length': { 'special length': {
'a119de63e4b2398427da06dd780263b3': '0123456780123456780123456780123456780123456780123456780', 'a119de63e4b2398427da06dd780263b3': '0123456780123456780123456780123456780123456780123456780',
'ddafd84ebe63aebc4626b037a569d78b': '01234567801234567801234567801234567801234567801234567801', 'ddafd84ebe63aebc4626b037a569d78b': '01234567801234567801234567801234567801234567801234567801',
@@ -89,6 +99,11 @@
testCases['Int8Array'] = { testCases['Int8Array'] = {
'9e107d9d372bb6826bd81d3542a419d6': new Int8Array([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 Int8Array([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])
}; };
testCases['ArrayBuffer view'] = {
'71f3ccb98530e3072e2eaef01da20d8c': new Int8Array([-1, -128, 65, 0, -2]),
'050d144172d916d0846f839e0412e929': new Uint16Array(new Uint8Array([2, 1]).buffer),
'eb61eead90e3b899c6bcbe27ac581660': new DataView(new Uint8Array([9, 72, 69, 76, 76, 79, 9]).buffer, 1, 5)
};
testCases['ArrayBuffer'] = { testCases['ArrayBuffer'] = {
'93b885adfe0da089cdf634904fd59f71': new ArrayBuffer(1) '93b885adfe0da089cdf634904fd59f71': new ArrayBuffer(1)
}; };