js-md5 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE.txt +1 -1
- package/README.md +18 -2
- package/build/md5.min.js +3 -3
- package/index.d.ts +148 -0
- package/package.json +15 -10
- package/src/md5.js +272 -79
- package/.covignore +0 -2
- package/.npmignore +0 -2
- package/.travis.yml +0 -11
- package/bower.json +0 -8
- package/doc/Md5_.html +0 -1194
- package/doc/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/doc/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/doc/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/doc/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/doc/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/doc/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/doc/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/doc/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/doc/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/doc/fonts/OpenSans-Light-webfont.eot +0 -0
- package/doc/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/doc/fonts/OpenSans-Light-webfont.woff +0 -0
- package/doc/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/doc/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/doc/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/doc/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/doc/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/doc/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/doc/global.html +0 -309
- package/doc/index.html +0 -105
- package/doc/md5.html +0 -1469
- package/doc/md5.js.html +0 -734
- package/doc/scripts/linenumber.js +0 -25
- package/doc/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/doc/scripts/prettify/lang-css.js +0 -2
- package/doc/scripts/prettify/prettify.js +0 -28
- package/doc/styles/jsdoc-default.css +0 -358
- package/doc/styles/prettify-jsdoc.css +0 -111
- package/doc/styles/prettify-tomorrow.css +0 -132
- package/tests/index.html +0 -22
- package/tests/node-test.js +0 -100
- package/tests/requirejs.html +0 -24
- package/tests/test.js +0 -270
- package/tests/worker-test.js +0 -21
- package/tests/worker.html +0 -26
- package/tests/worker.js +0 -12
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/* JSDoc prettify.js theme */
|
|
2
|
-
|
|
3
|
-
/* plain text */
|
|
4
|
-
.pln {
|
|
5
|
-
color: #000000;
|
|
6
|
-
font-weight: normal;
|
|
7
|
-
font-style: normal;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/* string content */
|
|
11
|
-
.str {
|
|
12
|
-
color: #006400;
|
|
13
|
-
font-weight: normal;
|
|
14
|
-
font-style: normal;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/* a keyword */
|
|
18
|
-
.kwd {
|
|
19
|
-
color: #000000;
|
|
20
|
-
font-weight: bold;
|
|
21
|
-
font-style: normal;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/* a comment */
|
|
25
|
-
.com {
|
|
26
|
-
font-weight: normal;
|
|
27
|
-
font-style: italic;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* a type name */
|
|
31
|
-
.typ {
|
|
32
|
-
color: #000000;
|
|
33
|
-
font-weight: normal;
|
|
34
|
-
font-style: normal;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* a literal value */
|
|
38
|
-
.lit {
|
|
39
|
-
color: #006400;
|
|
40
|
-
font-weight: normal;
|
|
41
|
-
font-style: normal;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* punctuation */
|
|
45
|
-
.pun {
|
|
46
|
-
color: #000000;
|
|
47
|
-
font-weight: bold;
|
|
48
|
-
font-style: normal;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/* lisp open bracket */
|
|
52
|
-
.opn {
|
|
53
|
-
color: #000000;
|
|
54
|
-
font-weight: bold;
|
|
55
|
-
font-style: normal;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* lisp close bracket */
|
|
59
|
-
.clo {
|
|
60
|
-
color: #000000;
|
|
61
|
-
font-weight: bold;
|
|
62
|
-
font-style: normal;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/* a markup tag name */
|
|
66
|
-
.tag {
|
|
67
|
-
color: #006400;
|
|
68
|
-
font-weight: normal;
|
|
69
|
-
font-style: normal;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/* a markup attribute name */
|
|
73
|
-
.atn {
|
|
74
|
-
color: #006400;
|
|
75
|
-
font-weight: normal;
|
|
76
|
-
font-style: normal;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* a markup attribute value */
|
|
80
|
-
.atv {
|
|
81
|
-
color: #006400;
|
|
82
|
-
font-weight: normal;
|
|
83
|
-
font-style: normal;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/* a declaration */
|
|
87
|
-
.dec {
|
|
88
|
-
color: #000000;
|
|
89
|
-
font-weight: bold;
|
|
90
|
-
font-style: normal;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* a variable name */
|
|
94
|
-
.var {
|
|
95
|
-
color: #000000;
|
|
96
|
-
font-weight: normal;
|
|
97
|
-
font-style: normal;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/* a function name */
|
|
101
|
-
.fun {
|
|
102
|
-
color: #000000;
|
|
103
|
-
font-weight: bold;
|
|
104
|
-
font-style: normal;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/* Specify class=linenums on a pre to get line numbering */
|
|
108
|
-
ol.linenums {
|
|
109
|
-
margin-top: 0;
|
|
110
|
-
margin-bottom: 0;
|
|
111
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/* Tomorrow Theme */
|
|
2
|
-
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
|
3
|
-
/* Pretty printing styles. Used with prettify.js. */
|
|
4
|
-
/* SPAN elements with the classes below are added by prettyprint. */
|
|
5
|
-
/* plain text */
|
|
6
|
-
.pln {
|
|
7
|
-
color: #4d4d4c; }
|
|
8
|
-
|
|
9
|
-
@media screen {
|
|
10
|
-
/* string content */
|
|
11
|
-
.str {
|
|
12
|
-
color: #718c00; }
|
|
13
|
-
|
|
14
|
-
/* a keyword */
|
|
15
|
-
.kwd {
|
|
16
|
-
color: #8959a8; }
|
|
17
|
-
|
|
18
|
-
/* a comment */
|
|
19
|
-
.com {
|
|
20
|
-
color: #8e908c; }
|
|
21
|
-
|
|
22
|
-
/* a type name */
|
|
23
|
-
.typ {
|
|
24
|
-
color: #4271ae; }
|
|
25
|
-
|
|
26
|
-
/* a literal value */
|
|
27
|
-
.lit {
|
|
28
|
-
color: #f5871f; }
|
|
29
|
-
|
|
30
|
-
/* punctuation */
|
|
31
|
-
.pun {
|
|
32
|
-
color: #4d4d4c; }
|
|
33
|
-
|
|
34
|
-
/* lisp open bracket */
|
|
35
|
-
.opn {
|
|
36
|
-
color: #4d4d4c; }
|
|
37
|
-
|
|
38
|
-
/* lisp close bracket */
|
|
39
|
-
.clo {
|
|
40
|
-
color: #4d4d4c; }
|
|
41
|
-
|
|
42
|
-
/* a markup tag name */
|
|
43
|
-
.tag {
|
|
44
|
-
color: #c82829; }
|
|
45
|
-
|
|
46
|
-
/* a markup attribute name */
|
|
47
|
-
.atn {
|
|
48
|
-
color: #f5871f; }
|
|
49
|
-
|
|
50
|
-
/* a markup attribute value */
|
|
51
|
-
.atv {
|
|
52
|
-
color: #3e999f; }
|
|
53
|
-
|
|
54
|
-
/* a declaration */
|
|
55
|
-
.dec {
|
|
56
|
-
color: #f5871f; }
|
|
57
|
-
|
|
58
|
-
/* a variable name */
|
|
59
|
-
.var {
|
|
60
|
-
color: #c82829; }
|
|
61
|
-
|
|
62
|
-
/* a function name */
|
|
63
|
-
.fun {
|
|
64
|
-
color: #4271ae; } }
|
|
65
|
-
/* Use higher contrast and text-weight for printable form. */
|
|
66
|
-
@media print, projection {
|
|
67
|
-
.str {
|
|
68
|
-
color: #060; }
|
|
69
|
-
|
|
70
|
-
.kwd {
|
|
71
|
-
color: #006;
|
|
72
|
-
font-weight: bold; }
|
|
73
|
-
|
|
74
|
-
.com {
|
|
75
|
-
color: #600;
|
|
76
|
-
font-style: italic; }
|
|
77
|
-
|
|
78
|
-
.typ {
|
|
79
|
-
color: #404;
|
|
80
|
-
font-weight: bold; }
|
|
81
|
-
|
|
82
|
-
.lit {
|
|
83
|
-
color: #044; }
|
|
84
|
-
|
|
85
|
-
.pun, .opn, .clo {
|
|
86
|
-
color: #440; }
|
|
87
|
-
|
|
88
|
-
.tag {
|
|
89
|
-
color: #006;
|
|
90
|
-
font-weight: bold; }
|
|
91
|
-
|
|
92
|
-
.atn {
|
|
93
|
-
color: #404; }
|
|
94
|
-
|
|
95
|
-
.atv {
|
|
96
|
-
color: #060; } }
|
|
97
|
-
/* Style */
|
|
98
|
-
/*
|
|
99
|
-
pre.prettyprint {
|
|
100
|
-
background: white;
|
|
101
|
-
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
|
102
|
-
font-size: 12px;
|
|
103
|
-
line-height: 1.5;
|
|
104
|
-
border: 1px solid #ccc;
|
|
105
|
-
padding: 10px; }
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
|
-
/* Specify class=linenums on a pre to get line numbering */
|
|
109
|
-
ol.linenums {
|
|
110
|
-
margin-top: 0;
|
|
111
|
-
margin-bottom: 0; }
|
|
112
|
-
|
|
113
|
-
/* IE indents via margin-left */
|
|
114
|
-
li.L0,
|
|
115
|
-
li.L1,
|
|
116
|
-
li.L2,
|
|
117
|
-
li.L3,
|
|
118
|
-
li.L4,
|
|
119
|
-
li.L5,
|
|
120
|
-
li.L6,
|
|
121
|
-
li.L7,
|
|
122
|
-
li.L8,
|
|
123
|
-
li.L9 {
|
|
124
|
-
/* */ }
|
|
125
|
-
|
|
126
|
-
/* Alternate shading for lines */
|
|
127
|
-
li.L1,
|
|
128
|
-
li.L3,
|
|
129
|
-
li.L5,
|
|
130
|
-
li.L7,
|
|
131
|
-
li.L9 {
|
|
132
|
-
/* */ }
|
package/tests/index.html
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>MD5</title>
|
|
6
|
-
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
|
7
|
-
<script src="../node_modules/mocha/mocha.js"></script>
|
|
8
|
-
<script src="../node_modules/expect.js/index.js"></script>
|
|
9
|
-
<script src="../src/md5.js"></script>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div id="mocha"></div>
|
|
13
|
-
<script>
|
|
14
|
-
mocha.setup('bdd');
|
|
15
|
-
</script>
|
|
16
|
-
<script src="test.js"></script>
|
|
17
|
-
<script>
|
|
18
|
-
mocha.checkLeaks();
|
|
19
|
-
mocha.run();
|
|
20
|
-
</script>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
package/tests/node-test.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
expect = require('expect.js');
|
|
2
|
-
Worker = require('webworker-threads').Worker;
|
|
3
|
-
|
|
4
|
-
function unset() {
|
|
5
|
-
delete require.cache[require.resolve('../src/md5.js')];
|
|
6
|
-
delete require.cache[require.resolve('./test.js')];
|
|
7
|
-
md5 = null;
|
|
8
|
-
BUFFER = undefined;
|
|
9
|
-
JS_MD5_NO_WINDOW = undefined;
|
|
10
|
-
JS_MD5_NO_NODE_JS = undefined;
|
|
11
|
-
JS_MD5_NO_COMMON_JS = undefined;
|
|
12
|
-
JS_MD5_NO_ARRAY_BUFFER = undefined;
|
|
13
|
-
JS_MD5_NO_ARRAY_BUFFER_IS_VIEW = undefined;
|
|
14
|
-
window = undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function runCommonJsTest() {
|
|
18
|
-
md5 = require('../src/md5.js');
|
|
19
|
-
require('./test.js');
|
|
20
|
-
unset();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function runWindowTest() {
|
|
24
|
-
window = global;
|
|
25
|
-
require('../src/md5.js');
|
|
26
|
-
require('./test.js');
|
|
27
|
-
unset();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Node.js env
|
|
31
|
-
BUFFER = true;
|
|
32
|
-
runCommonJsTest();
|
|
33
|
-
|
|
34
|
-
// Webpack browser env
|
|
35
|
-
JS_MD5_NO_NODE_JS = true;
|
|
36
|
-
runCommonJsTest();
|
|
37
|
-
|
|
38
|
-
// browser env
|
|
39
|
-
JS_MD5_NO_NODE_JS = true;
|
|
40
|
-
JS_MD5_NO_COMMON_JS = true;
|
|
41
|
-
runWindowTest();
|
|
42
|
-
|
|
43
|
-
// browser env and no array buffer
|
|
44
|
-
JS_MD5_NO_NODE_JS = true;
|
|
45
|
-
JS_MD5_NO_COMMON_JS = true;
|
|
46
|
-
JS_MD5_NO_ARRAY_BUFFER = true;
|
|
47
|
-
runWindowTest();
|
|
48
|
-
|
|
49
|
-
// browser env and no isView
|
|
50
|
-
JS_MD5_NO_NODE_JS = true;
|
|
51
|
-
JS_MD5_NO_COMMON_JS = true;
|
|
52
|
-
JS_MD5_NO_ARRAY_BUFFER_IS_VIEW = true;
|
|
53
|
-
runWindowTest();
|
|
54
|
-
|
|
55
|
-
// browser AMD
|
|
56
|
-
JS_MD5_NO_NODE_JS = true;
|
|
57
|
-
JS_MD5_NO_COMMON_JS = true;
|
|
58
|
-
window = global;
|
|
59
|
-
define = function (func) {
|
|
60
|
-
md5 = func();
|
|
61
|
-
require('./test.js');
|
|
62
|
-
};
|
|
63
|
-
define.amd = true;
|
|
64
|
-
|
|
65
|
-
require('../src/md5.js');
|
|
66
|
-
unset();
|
|
67
|
-
|
|
68
|
-
// webworker
|
|
69
|
-
WORKER = 'tests/worker.js';
|
|
70
|
-
SOURCE = 'src/md5.js';
|
|
71
|
-
|
|
72
|
-
require('./worker-test.js');
|
|
73
|
-
|
|
74
|
-
delete require.cache[require.resolve('./worker-test.js')];
|
|
75
|
-
|
|
76
|
-
// cover webworker
|
|
77
|
-
JS_MD5_NO_WINDOW = true;
|
|
78
|
-
JS_MD5_NO_NODE_JS = true;
|
|
79
|
-
WORKER = './worker.js';
|
|
80
|
-
SOURCE = '../src/md5.js';
|
|
81
|
-
window = global;
|
|
82
|
-
self = global;
|
|
83
|
-
|
|
84
|
-
Worker = function (file) {
|
|
85
|
-
require(file);
|
|
86
|
-
currentWorker = this;
|
|
87
|
-
|
|
88
|
-
this.postMessage = function (data) {
|
|
89
|
-
onmessage({data: data});
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
postMessage = function (data) {
|
|
94
|
-
currentWorker.onmessage({data: data});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
importScripts = function () {};
|
|
98
|
-
|
|
99
|
-
md5 = require('../src/md5.js');
|
|
100
|
-
require('./worker-test.js');
|
package/tests/requirejs.html
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>MD5</title>
|
|
6
|
-
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
|
7
|
-
<script src="../node_modules/mocha/mocha.js"></script>
|
|
8
|
-
<script src="../node_modules/expect.js/index.js"></script>
|
|
9
|
-
<script src="../node_modules/requirejs/require.js"></script>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div id="mocha"></div>
|
|
13
|
-
<script>
|
|
14
|
-
mocha.setup('bdd');
|
|
15
|
-
require(['../src/md5.js'], function (md5) {
|
|
16
|
-
window.md5 = md5;
|
|
17
|
-
require(['test.js'], function () {
|
|
18
|
-
mocha.checkLeaks();
|
|
19
|
-
mocha.run();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
</script>
|
|
23
|
-
</body>
|
|
24
|
-
</html>
|
package/tests/test.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
(function (md5) {
|
|
2
|
-
Array.prototype.toHexString = ArrayBuffer.prototype.toHexString = function () {
|
|
3
|
-
var array = new Uint8Array(this);
|
|
4
|
-
var hex = '';
|
|
5
|
-
for (var i = 0; i < array.length; ++i) {
|
|
6
|
-
var c = array[i].toString('16');
|
|
7
|
-
hex += c.length == 1 ? '0' + c : c;
|
|
8
|
-
}
|
|
9
|
-
return hex;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
var testCases = {
|
|
13
|
-
'ascii': {
|
|
14
|
-
'd41d8cd98f00b204e9800998ecf8427e': '',
|
|
15
|
-
'9e107d9d372bb6826bd81d3542a419d6': 'The quick brown fox jumps over the lazy dog',
|
|
16
|
-
'e4d909c290d0fb1ca068ffaddf22cbd0': 'The quick brown fox jumps over the lazy dog.'
|
|
17
|
-
},
|
|
18
|
-
'ascii more than 64 bytes': {
|
|
19
|
-
'f63872ef7bc97a8a8eadba6f0881de53': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
20
|
-
},
|
|
21
|
-
'UTF8': {
|
|
22
|
-
'a7bac2239fcdcb3a067903d8077c4a07': '中文',
|
|
23
|
-
'ec3edbf3b05a449fc206a0138c739c3b': 'aécio',
|
|
24
|
-
'b90869aaf121210f6c563973fa855650': '𠜎'
|
|
25
|
-
},
|
|
26
|
-
'UTF8 more than 64 bytes': {
|
|
27
|
-
'edce615b179e6e29be23145b77ebbd61': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
28
|
-
'ad36c9ab669a0ba9ce46d3ce9134de34': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
29
|
-
},
|
|
30
|
-
'special length': {
|
|
31
|
-
'a119de63e4b2398427da06dd780263b3': '0123456780123456780123456780123456780123456780123456780',
|
|
32
|
-
'ddafd84ebe63aebc4626b037a569d78b': '01234567801234567801234567801234567801234567801234567801',
|
|
33
|
-
'9ea04d743618797ce464445b5785a630': '0123456780123456780123456780123456780123456780123456780123456780',
|
|
34
|
-
'658d914ae42c4938874b2e786ccda479': '01234567801234567801234567801234567801234567801234567801234567801234567',
|
|
35
|
-
'a083a3710d685793f1f17988bfe3c175': '012345678012345678012345678012345678012345678012345678012345678012345678',
|
|
36
|
-
'2b21a843cfc31c8026a0d835bc91bc98': '012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678',
|
|
37
|
-
'd02ebde979264c79e141559fc9f6b65c': '012345678901234567',
|
|
38
|
-
'1ced811af47ead374872fcca9d73dd71': '012345678901234567890123456789012345678901234567890123456789',
|
|
39
|
-
'ffb81a243a60dac45929300873e05287': '012345678901234567中文',
|
|
40
|
-
},
|
|
41
|
-
'Array': {
|
|
42
|
-
'd41d8cd98f00b204e9800998ecf8427e': [],
|
|
43
|
-
'93b885adfe0da089cdf634904fd59f71': [0],
|
|
44
|
-
'9e107d9d372bb6826bd81d3542a419d6': [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]
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var base64TestCases = {
|
|
50
|
-
'ascii': {
|
|
51
|
-
'1B2M2Y8AsgTpgAmY7PhCfg==': '',
|
|
52
|
-
'nhB9nTcrtoJr2B01QqQZ1g==': 'The quick brown fox jumps over the lazy dog',
|
|
53
|
-
'5NkJwpDQ+xygaP+t3yLL0A==': 'The quick brown fox jumps over the lazy dog.'
|
|
54
|
-
},
|
|
55
|
-
'ascii more than 64 bytes': {
|
|
56
|
-
'9jhy73vJeoqOrbpvCIHeUw==': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
57
|
-
},
|
|
58
|
-
'UTF8': {
|
|
59
|
-
'p7rCI5/NyzoGeQPYB3xKBw==': '中文',
|
|
60
|
-
'7D7b87BaRJ/CBqATjHOcOw==': 'aécio',
|
|
61
|
-
'uQhpqvEhIQ9sVjlz+oVWUA==': '𠜎'
|
|
62
|
-
},
|
|
63
|
-
'UTF8 more than 64 bytes': {
|
|
64
|
-
'7c5hWxeebim+IxRbd+u9YQ==': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
65
|
-
'rTbJq2aaC6nORtPOkTTeNA==': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
66
|
-
},
|
|
67
|
-
'special length': {
|
|
68
|
-
'oRneY+SyOYQn2gbdeAJjsw==': '0123456780123456780123456780123456780123456780123456780',
|
|
69
|
-
'3a/YTr5jrrxGJrA3pWnXiw==': '01234567801234567801234567801234567801234567801234567801',
|
|
70
|
-
'nqBNdDYYeXzkZERbV4WmMA==': '0123456780123456780123456780123456780123456780123456780123456780',
|
|
71
|
-
'ZY2RSuQsSTiHSy54bM2keQ==': '01234567801234567801234567801234567801234567801234567801234567801234567',
|
|
72
|
-
'oIOjcQ1oV5Px8XmIv+PBdQ==': '012345678012345678012345678012345678012345678012345678012345678012345678',
|
|
73
|
-
'KyGoQ8/DHIAmoNg1vJG8mA==': '012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678012345678',
|
|
74
|
-
'0C696XkmTHnhQVWfyfa2XA==': '012345678901234567',
|
|
75
|
-
'HO2BGvR+rTdIcvzKnXPdcQ==': '012345678901234567890123456789012345678901234567890123456789',
|
|
76
|
-
'/7gaJDpg2sRZKTAIc+BShw==': '012345678901234567中文',
|
|
77
|
-
},
|
|
78
|
-
'Array': {
|
|
79
|
-
'1B2M2Y8AsgTpgAmY7PhCfg==': [],
|
|
80
|
-
'k7iFrf4NoInN9jSQT9WfcQ==': [0],
|
|
81
|
-
'nhB9nTcrtoJr2B01QqQZ1g==': [84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
if (!(typeof JS_MD5_NO_ARRAY_BUFFER === 'boolean' && JS_MD5_NO_ARRAY_BUFFER)) {
|
|
86
|
-
testCases['Uint8Array'] = {
|
|
87
|
-
'9e107d9d372bb6826bd81d3542a419d6': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
|
|
88
|
-
};
|
|
89
|
-
testCases['Int8Array'] = {
|
|
90
|
-
'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])
|
|
91
|
-
};
|
|
92
|
-
testCases['ArrayBuffer'] = {
|
|
93
|
-
'93b885adfe0da089cdf634904fd59f71': new ArrayBuffer(1)
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (typeof BUFFER === 'boolean' && BUFFER) {
|
|
98
|
-
testCases['Buffer'] = {
|
|
99
|
-
'd41d8cd98f00b204e9800998ecf8427e': new Buffer(0),
|
|
100
|
-
'9e107d9d372bb6826bd81d3542a419d6': new Buffer(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var errorTestCases = [null, undefined, { length: 0 }, 0, 1, false, true, NaN, Infinity, function () {}];
|
|
105
|
-
|
|
106
|
-
var methods = [
|
|
107
|
-
{
|
|
108
|
-
name: 'md5',
|
|
109
|
-
call: md5,
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: 'md5.hex',
|
|
113
|
-
call: md5.hex
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: 'md5.array',
|
|
117
|
-
call: function (message) {
|
|
118
|
-
return md5.array(message).toHexString();
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: 'md5.digest',
|
|
123
|
-
call: function (message) {
|
|
124
|
-
return md5.digest(message).toHexString();
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: 'md5.arrayBuffer',
|
|
129
|
-
call: function (message) {
|
|
130
|
-
return md5.arrayBuffer(message).toHexString();
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
name: 'md5.buffer',
|
|
135
|
-
call: function (message) {
|
|
136
|
-
return md5.buffer(message).toHexString();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
];
|
|
140
|
-
|
|
141
|
-
var classMethods = [
|
|
142
|
-
{
|
|
143
|
-
name: 'create',
|
|
144
|
-
call: function (message) {
|
|
145
|
-
return md5.create().update(message).toString();
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: 'update',
|
|
150
|
-
call: function (message) {
|
|
151
|
-
return md5.update(message).toString();
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
name: 'hex',
|
|
156
|
-
call: function (message) {
|
|
157
|
-
return md5.update(message).hex();
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
name: 'array',
|
|
162
|
-
call: function (message) {
|
|
163
|
-
return md5.update(message).array().toHexString();
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
name: 'digest',
|
|
168
|
-
call: function (message) {
|
|
169
|
-
return md5.update(message).digest().toHexString();
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: 'arrayBuffer',
|
|
174
|
-
call: function (message) {
|
|
175
|
-
return md5.update(message).arrayBuffer().toHexString();
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
name: 'buffer',
|
|
180
|
-
call: function (message) {
|
|
181
|
-
return md5.update(message).buffer().toHexString();
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: 'finalize',
|
|
186
|
-
call: function (message) {
|
|
187
|
-
var hash = md5.update(message);
|
|
188
|
-
hash.hex();
|
|
189
|
-
hash.update(message);
|
|
190
|
-
return hash.hex();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
];
|
|
194
|
-
|
|
195
|
-
describe('md5', function () {
|
|
196
|
-
methods.forEach(function (method) {
|
|
197
|
-
describe('#' + method.name, function () {
|
|
198
|
-
for (var testCaseName in testCases) {
|
|
199
|
-
(function (testCaseName) {
|
|
200
|
-
var testCase = testCases[testCaseName];
|
|
201
|
-
context('when ' + testCaseName, function () {
|
|
202
|
-
for (var hash in testCase) {
|
|
203
|
-
(function (message, hash) {
|
|
204
|
-
it('should be equal', function () {
|
|
205
|
-
expect(method.call(message)).to.be(hash);
|
|
206
|
-
});
|
|
207
|
-
})(testCase[hash], hash);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
})(testCaseName);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
classMethods.forEach(function (method) {
|
|
216
|
-
describe('#' + method.name, function () {
|
|
217
|
-
for (var testCaseName in testCases) {
|
|
218
|
-
(function (testCaseName) {
|
|
219
|
-
var testCase = testCases[testCaseName];
|
|
220
|
-
context('when ' + testCaseName, function () {
|
|
221
|
-
for (var hash in testCase) {
|
|
222
|
-
(function (message, hash) {
|
|
223
|
-
it('should be equal', function () {
|
|
224
|
-
expect(method.call(message)).to.be(hash);
|
|
225
|
-
});
|
|
226
|
-
})(testCase[hash], hash);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
})(testCaseName);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
describe('#md5', function () {
|
|
235
|
-
errorTestCases.forEach(function (testCase) {
|
|
236
|
-
context('when ' + testCase, function () {
|
|
237
|
-
it('should throw error', function () {
|
|
238
|
-
expect(function () {
|
|
239
|
-
md5(testCase);
|
|
240
|
-
}).to.throwError(/input is invalid type/);
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
context('when large size', function () {
|
|
246
|
-
var hash = md5.create();
|
|
247
|
-
hash.bytes = 4294967295;
|
|
248
|
-
hash.update('any');
|
|
249
|
-
expect(hash.hBytes).to.be(1);
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
describe('#bas64', function () {
|
|
254
|
-
for (var testCaseName in base64TestCases) {
|
|
255
|
-
var testCase = base64TestCases[testCaseName];
|
|
256
|
-
context('when ' + testCaseName, function () {
|
|
257
|
-
for (var hash in testCase) {
|
|
258
|
-
(function (message, hash) {
|
|
259
|
-
it('should be equal', function () {
|
|
260
|
-
expect(md5.base64(message)).to.be(hash);
|
|
261
|
-
expect(md5.create().update(message).base64()).to.be(hash);
|
|
262
|
-
expect(md5.update(message).base64()).to.be(hash);
|
|
263
|
-
});
|
|
264
|
-
})(testCase[hash], hash);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
})(md5);
|
package/tests/worker-test.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
(function (Worker, WORKER, SOURCE) {
|
|
2
|
-
var cases = {
|
|
3
|
-
'd41d8cd98f00b204e9800998ecf8427e': '',
|
|
4
|
-
'9e107d9d372bb6826bd81d3542a419d6': 'The quick brown fox jumps over the lazy dog',
|
|
5
|
-
'e4d909c290d0fb1ca068ffaddf22cbd0': 'The quick brown fox jumps over the lazy dog.'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
describe('#md5', function () {
|
|
9
|
-
Object.keys(cases).forEach(function (hash) {
|
|
10
|
-
it('should be equal', function (done) {
|
|
11
|
-
var worker = new Worker(WORKER);
|
|
12
|
-
worker.onmessage = function(event) {
|
|
13
|
-
expect(event.data).to.be(hash);
|
|
14
|
-
done();
|
|
15
|
-
};
|
|
16
|
-
worker.postMessage(SOURCE);
|
|
17
|
-
worker.postMessage(cases[hash]);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
})(Worker, WORKER, SOURCE);
|