forked from blueimp/JavaScript-MD5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
100 lines (81 loc) · 2.57 KB
/
test.js
File metadata and controls
100 lines (81 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* JavaScript MD5 Test 1.0.1
* https://github.com/blueimp/JavaScript-MD5
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*global describe, it, expect, require */
(function (expect, md5) {
'use strict';
describe('MD5 Hex-encoding', function () {
it('should create a hex-encoded MD5 hash of an ASCII value', function () {
expect(
md5('value')
).to.be(
'2063c1608d6e0baf80249c42e2be5804'
);
});
it('should create a hex-encoded MD5 hash of an UTF-8 value', function () {
expect(
md5('日本')
).to.be(
'4dbed2e657457884e67137d3514119b3'
);
});
});
describe('HMAC-MD5 Hex-encoding', function () {
it('should create a hex-encoded HMAC-MD5 hash of an ASCII value and key', function () {
expect(
md5('value', 'key')
).to.be(
'01433efd5f16327ea4b31144572c67f6'
);
});
it('should create a hex-encoded HMAC-MD5 hash of an UTF-8 value and key', function () {
expect(
md5('日本', '日本')
).to.be(
'c78b8c7357926981cc04740bd3e9d015'
);
});
});
describe('MD5 raw encoding', function () {
it('should create a raw MD5 hash of an ASCII value', function () {
expect(
md5('value', null, true)
).to.be(
' c\xc1`\x8dn\x0b\xaf\x80$\x9cB\xe2\xbeX\x04'
);
});
it('should create a raw MD5 hash of an UTF-8 value', function () {
expect(
md5('日本', null, true)
).to.be(
'M\xbe\xd2\xe6WEx\x84\xe6q7\xd3QA\x19\xb3'
);
});
});
describe('HMAC-MD5 raw encoding', function () {
it('should create a raw HMAC-MD5 hash of an ASCII value and key', function () {
expect(
md5('value', 'key', true)
).to.be(
'\x01C>\xfd_\x162~\xa4\xb3\x11DW,g\xf6'
);
});
it('should create a raw HMAC-MD5 hash of an UTF-8 value and key', function () {
expect(
md5('日本', '日本', true)
).to.be(
'\xc7\x8b\x8csW\x92i\x81\xcc\x04t\x0b\xd3\xe9\xd0\x15'
);
});
});
}(
this.expect || require('expect.js'),
this.md5 || require('../js/md5').md5
));