@ivujs/i-utils 1.1.1

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.
Files changed (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -0
  3. package/dist/cjs/ID-card/index.cjs +122 -0
  4. package/dist/cjs/array/index.cjs +465 -0
  5. package/dist/cjs/clipboard/index.cjs +135 -0
  6. package/dist/cjs/color/index.cjs +210 -0
  7. package/dist/cjs/constants/date.cjs +186 -0
  8. package/dist/cjs/constants/lang.cjs +13 -0
  9. package/dist/cjs/constants/math.cjs +13 -0
  10. package/dist/cjs/constants/regexp.cjs +57 -0
  11. package/dist/cjs/constants/sort.cjs +15 -0
  12. package/dist/cjs/cookie/index.cjs +71 -0
  13. package/dist/cjs/crypto/aes/aes.cjs +533 -0
  14. package/dist/cjs/crypto/aes/index.cjs +28 -0
  15. package/dist/cjs/crypto/base32/base32.cjs +385 -0
  16. package/dist/cjs/crypto/base32/index.cjs +44 -0
  17. package/dist/cjs/crypto/base64/base64.cjs +433 -0
  18. package/dist/cjs/crypto/base64/index.cjs +64 -0
  19. package/dist/cjs/crypto/des/des.cjs +1054 -0
  20. package/dist/cjs/crypto/des/index.cjs +30 -0
  21. package/dist/cjs/crypto/md5/index.cjs +25 -0
  22. package/dist/cjs/crypto/md5/md5.cjs +944 -0
  23. package/dist/cjs/crypto/sha/sha1/index.cjs +25 -0
  24. package/dist/cjs/crypto/sha/sha1/sha1.cjs +602 -0
  25. package/dist/cjs/crypto/sha/sha256/index.cjs +46 -0
  26. package/dist/cjs/crypto/sha/sha256/sha256.cjs +654 -0
  27. package/dist/cjs/crypto/sha/sha3/index.cjs +44 -0
  28. package/dist/cjs/crypto/sha/sha3/sha3.cjs +747 -0
  29. package/dist/cjs/crypto/sha/sha512/index.cjs +88 -0
  30. package/dist/cjs/crypto/sha/sha512/sha512.cjs +1186 -0
  31. package/dist/cjs/crypto/sm/lib/asn1.cjs +167 -0
  32. package/dist/cjs/crypto/sm/lib/ec.cjs +352 -0
  33. package/dist/cjs/crypto/sm/lib/jsbn.cjs +1633 -0
  34. package/dist/cjs/crypto/sm/lib/sm3.cjs +173 -0
  35. package/dist/cjs/crypto/sm/lib/utils.cjs +198 -0
  36. package/dist/cjs/crypto/sm/sm2/index.cjs +122 -0
  37. package/dist/cjs/crypto/sm/sm2/sm2.cjs +269 -0
  38. package/dist/cjs/crypto/sm/sm3/index.cjs +15 -0
  39. package/dist/cjs/crypto/sm/sm3/sm3.cjs +103 -0
  40. package/dist/cjs/crypto/sm/sm4/index.cjs +28 -0
  41. package/dist/cjs/crypto/sm/sm4/sm4.cjs +362 -0
  42. package/dist/cjs/crypto/tea/index.cjs +26 -0
  43. package/dist/cjs/crypto/tea/tea.cjs +215 -0
  44. package/dist/cjs/date/index.cjs +1349 -0
  45. package/dist/cjs/desensitized/index.cjs +74 -0
  46. package/dist/cjs/device/index.cjs +159 -0
  47. package/dist/cjs/dom/index.cjs +176 -0
  48. package/dist/cjs/file/index.cjs +339 -0
  49. package/dist/cjs/function/index.cjs +67 -0
  50. package/dist/cjs/id/index.cjs +46 -0
  51. package/dist/cjs/index.cjs +399 -0
  52. package/dist/cjs/keycode/index.cjs +142 -0
  53. package/dist/cjs/math/index.cjs +284 -0
  54. package/dist/cjs/number/index.cjs +14 -0
  55. package/dist/cjs/object/index.cjs +216 -0
  56. package/dist/cjs/pagination/index.cjs +140 -0
  57. package/dist/cjs/random/index.cjs +25 -0
  58. package/dist/cjs/regexp/index.cjs +109 -0
  59. package/dist/cjs/storage/index.cjs +11 -0
  60. package/dist/cjs/storage/localStorage.cjs +40 -0
  61. package/dist/cjs/storage/sessionStorage.cjs +40 -0
  62. package/dist/cjs/string/index.cjs +338 -0
  63. package/dist/cjs/url/index.cjs +279 -0
  64. package/dist/cjs/validate/index.cjs +487 -0
  65. package/dist/cjs/weapp/index.cjs +151 -0
  66. package/dist/es/ID-card/index.mjs +116 -0
  67. package/dist/es/array/index.mjs +437 -0
  68. package/dist/es/clipboard/index.mjs +129 -0
  69. package/dist/es/color/index.mjs +200 -0
  70. package/dist/es/constants/date.mjs +184 -0
  71. package/dist/es/constants/lang.mjs +11 -0
  72. package/dist/es/constants/math.mjs +11 -0
  73. package/dist/es/constants/regexp.mjs +55 -0
  74. package/dist/es/constants/sort.mjs +13 -0
  75. package/dist/es/cookie/index.mjs +65 -0
  76. package/dist/es/crypto/aes/aes.mjs +529 -0
  77. package/dist/es/crypto/aes/index.mjs +25 -0
  78. package/dist/es/crypto/base32/base32.mjs +381 -0
  79. package/dist/es/crypto/base32/index.mjs +39 -0
  80. package/dist/es/crypto/base64/base64.mjs +427 -0
  81. package/dist/es/crypto/base64/index.mjs +57 -0
  82. package/dist/es/crypto/des/des.mjs +1050 -0
  83. package/dist/es/crypto/des/index.mjs +27 -0
  84. package/dist/es/crypto/md5/index.mjs +22 -0
  85. package/dist/es/crypto/md5/md5.mjs +941 -0
  86. package/dist/es/crypto/sha/sha1/index.mjs +22 -0
  87. package/dist/es/crypto/sha/sha1/sha1.mjs +599 -0
  88. package/dist/es/crypto/sha/sha256/index.mjs +41 -0
  89. package/dist/es/crypto/sha/sha256/sha256.mjs +649 -0
  90. package/dist/es/crypto/sha/sha3/index.mjs +39 -0
  91. package/dist/es/crypto/sha/sha3/sha3.mjs +742 -0
  92. package/dist/es/crypto/sha/sha512/index.mjs +79 -0
  93. package/dist/es/crypto/sha/sha512/sha512.mjs +1177 -0
  94. package/dist/es/crypto/sm/lib/asn1.mjs +164 -0
  95. package/dist/es/crypto/sm/lib/ec.mjs +349 -0
  96. package/dist/es/crypto/sm/lib/jsbn.mjs +1630 -0
  97. package/dist/es/crypto/sm/lib/sm3.mjs +170 -0
  98. package/dist/es/crypto/sm/lib/utils.mjs +186 -0
  99. package/dist/es/crypto/sm/sm2/index.mjs +111 -0
  100. package/dist/es/crypto/sm/sm2/sm2.mjs +258 -0
  101. package/dist/es/crypto/sm/sm3/index.mjs +13 -0
  102. package/dist/es/crypto/sm/sm3/sm3.mjs +99 -0
  103. package/dist/es/crypto/sm/sm4/index.mjs +25 -0
  104. package/dist/es/crypto/sm/sm4/sm4.mjs +359 -0
  105. package/dist/es/crypto/tea/index.mjs +23 -0
  106. package/dist/es/crypto/tea/tea.mjs +211 -0
  107. package/dist/es/date/index.mjs +1262 -0
  108. package/dist/es/desensitized/index.mjs +69 -0
  109. package/dist/es/device/index.mjs +145 -0
  110. package/dist/es/dom/index.mjs +164 -0
  111. package/dist/es/file/index.mjs +323 -0
  112. package/dist/es/function/index.mjs +63 -0
  113. package/dist/es/id/index.mjs +43 -0
  114. package/dist/es/index.mjs +59 -0
  115. package/dist/es/keycode/index.mjs +139 -0
  116. package/dist/es/math/index.mjs +274 -0
  117. package/dist/es/number/index.mjs +12 -0
  118. package/dist/es/object/index.mjs +203 -0
  119. package/dist/es/pagination/index.mjs +134 -0
  120. package/dist/es/random/index.mjs +22 -0
  121. package/dist/es/regexp/index.mjs +98 -0
  122. package/dist/es/storage/index.mjs +9 -0
  123. package/dist/es/storage/localStorage.mjs +35 -0
  124. package/dist/es/storage/sessionStorage.mjs +35 -0
  125. package/dist/es/string/index.mjs +321 -0
  126. package/dist/es/url/index.mjs +261 -0
  127. package/dist/es/validate/index.mjs +451 -0
  128. package/dist/es/weapp/index.mjs +140 -0
  129. package/dist/lib/index.full.esm.js +15825 -0
  130. package/dist/lib/index.full.esm.min.js +58 -0
  131. package/dist/lib/index.full.umd.js +16179 -0
  132. package/package.json +54 -0
@@ -0,0 +1,1186 @@
1
+ 'use strict';
2
+
3
+ /*
4
+ * [js-sha512]{@link https://github.com/emn178/js-sha512}
5
+ *
6
+ * @version 0.9.0
7
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
8
+ * @copyright Chen, Yi-Cyuan 2014-2024
9
+ * @license MIT
10
+ */
11
+ /* jslint bitwise: true */
12
+
13
+ var INPUT_ERROR = "input is invalid type";
14
+ var FINALIZE_ERROR = "finalize already called";
15
+ var WINDOW = typeof window === "object";
16
+ var root = WINDOW ? window : {};
17
+ if (root.JS_SHA512_NO_WINDOW) {
18
+ WINDOW = false;
19
+ }
20
+ var WEB_WORKER = !WINDOW && typeof self === "object";
21
+ var NODE_JS = !root.JS_SHA512_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node;
22
+ if (NODE_JS) {
23
+ root = global;
24
+ } else if (WEB_WORKER) {
25
+ root = self;
26
+ }
27
+ var ARRAY_BUFFER = !root.JS_SHA512_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
28
+ var HEX_CHARS = "0123456789abcdef".split("");
29
+ var EXTRA = [-2147483648, 8388608, 32768, 128];
30
+ var SHIFT = [24, 16, 8, 0];
31
+ var K = [
32
+ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 0x3956c25b,
33
+ 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 0xd807aa98, 0xa3030242,
34
+ 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, 0x72be5d74, 0xf27b896f, 0x80deb1fe,
35
+ 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
36
+ 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc,
37
+ 0xbd41fbd4, 0x76f988da, 0x831153b5, 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f,
38
+ 0xbf597fc7, 0xbeef0ee4, 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967,
39
+ 0x0a0e6e70, 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
40
+ 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, 0xa2bfe8a1,
41
+ 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, 0xd192e819, 0xd6ef5218,
42
+ 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, 0x19a4c116, 0xb8d2d0c8, 0x1e376c08,
43
+ 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
44
+ 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814,
45
+ 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915,
46
+ 0xc67178f2, 0xe372532b, 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f,
47
+ 0xee6ed178, 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
48
+ 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, 0x4cc5d4be,
49
+ 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817,
50
+ ];
51
+
52
+ var OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"];
53
+
54
+ var blocks = [];
55
+
56
+ var isArray = Array.isArray;
57
+ if (root.JS_SHA512_NO_NODE_JS || !isArray) {
58
+ isArray = function (obj) {
59
+ return Object.prototype.toString.call(obj) === "[object Array]";
60
+ };
61
+ }
62
+
63
+ var isView = ArrayBuffer.isView;
64
+ if (ARRAY_BUFFER && (root.JS_SHA512_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {
65
+ isView = function (obj) {
66
+ return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer;
67
+ };
68
+ }
69
+
70
+ // [message: string, isString: bool]
71
+ var formatMessage = function (message) {
72
+ var type = typeof message;
73
+ if (type === "string") {
74
+ return [message, true];
75
+ }
76
+ if (type !== "object" || message === null) {
77
+ throw new Error(INPUT_ERROR);
78
+ }
79
+ if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
80
+ return [new Uint8Array(message), false];
81
+ }
82
+ if (!isArray(message) && !isView(message)) {
83
+ throw new Error(INPUT_ERROR);
84
+ }
85
+ return [message, false];
86
+ };
87
+
88
+ var createOutputMethod = function (outputType, bits) {
89
+ return function (message) {
90
+ return new Sha512(bits, true).update(message)[outputType]();
91
+ };
92
+ };
93
+
94
+ var createMethod = function (bits) {
95
+ var method = createOutputMethod("hex", bits);
96
+ method.create = function () {
97
+ return new Sha512(bits);
98
+ };
99
+ method.update = function (message) {
100
+ return method.create().update(message);
101
+ };
102
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
103
+ var type = OUTPUT_TYPES[i];
104
+ method[type] = createOutputMethod(type, bits);
105
+ }
106
+ return method;
107
+ };
108
+
109
+ var createHmacOutputMethod = function (outputType, bits) {
110
+ return function (key, message) {
111
+ return new HmacSha512(key, bits, true).update(message)[outputType]();
112
+ };
113
+ };
114
+
115
+ var createHmacMethod = function (bits) {
116
+ var method = createHmacOutputMethod("hex", bits);
117
+ method.create = function (key) {
118
+ return new HmacSha512(key, bits);
119
+ };
120
+ method.update = function (key, message) {
121
+ return method.create(key).update(message);
122
+ };
123
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
124
+ var type = OUTPUT_TYPES[i];
125
+ method[type] = createHmacOutputMethod(type, bits);
126
+ }
127
+ return method;
128
+ };
129
+
130
+ function Sha512(bits, sharedMemory) {
131
+ if (sharedMemory) {
132
+ blocks[0] =
133
+ blocks[1] =
134
+ blocks[2] =
135
+ blocks[3] =
136
+ blocks[4] =
137
+ blocks[5] =
138
+ blocks[6] =
139
+ blocks[7] =
140
+ blocks[8] =
141
+ blocks[9] =
142
+ blocks[10] =
143
+ blocks[11] =
144
+ blocks[12] =
145
+ blocks[13] =
146
+ blocks[14] =
147
+ blocks[15] =
148
+ blocks[16] =
149
+ blocks[17] =
150
+ blocks[18] =
151
+ blocks[19] =
152
+ blocks[20] =
153
+ blocks[21] =
154
+ blocks[22] =
155
+ blocks[23] =
156
+ blocks[24] =
157
+ blocks[25] =
158
+ blocks[26] =
159
+ blocks[27] =
160
+ blocks[28] =
161
+ blocks[29] =
162
+ blocks[30] =
163
+ blocks[31] =
164
+ blocks[32] =
165
+ 0;
166
+ this.blocks = blocks;
167
+ } else {
168
+ this.blocks = [
169
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
170
+ ];
171
+ }
172
+
173
+ if (bits == 384) {
174
+ this.h0h = 0xcbbb9d5d;
175
+ this.h0l = 0xc1059ed8;
176
+ this.h1h = 0x629a292a;
177
+ this.h1l = 0x367cd507;
178
+ this.h2h = 0x9159015a;
179
+ this.h2l = 0x3070dd17;
180
+ this.h3h = 0x152fecd8;
181
+ this.h3l = 0xf70e5939;
182
+ this.h4h = 0x67332667;
183
+ this.h4l = 0xffc00b31;
184
+ this.h5h = 0x8eb44a87;
185
+ this.h5l = 0x68581511;
186
+ this.h6h = 0xdb0c2e0d;
187
+ this.h6l = 0x64f98fa7;
188
+ this.h7h = 0x47b5481d;
189
+ this.h7l = 0xbefa4fa4;
190
+ } else if (bits == 256) {
191
+ this.h0h = 0x22312194;
192
+ this.h0l = 0xfc2bf72c;
193
+ this.h1h = 0x9f555fa3;
194
+ this.h1l = 0xc84c64c2;
195
+ this.h2h = 0x2393b86b;
196
+ this.h2l = 0x6f53b151;
197
+ this.h3h = 0x96387719;
198
+ this.h3l = 0x5940eabd;
199
+ this.h4h = 0x96283ee2;
200
+ this.h4l = 0xa88effe3;
201
+ this.h5h = 0xbe5e1e25;
202
+ this.h5l = 0x53863992;
203
+ this.h6h = 0x2b0199fc;
204
+ this.h6l = 0x2c85b8aa;
205
+ this.h7h = 0x0eb72ddc;
206
+ this.h7l = 0x81c52ca2;
207
+ } else if (bits == 224) {
208
+ this.h0h = 0x8c3d37c8;
209
+ this.h0l = 0x19544da2;
210
+ this.h1h = 0x73e19966;
211
+ this.h1l = 0x89dcd4d6;
212
+ this.h2h = 0x1dfab7ae;
213
+ this.h2l = 0x32ff9c82;
214
+ this.h3h = 0x679dd514;
215
+ this.h3l = 0x582f9fcf;
216
+ this.h4h = 0x0f6d2b69;
217
+ this.h4l = 0x7bd44da8;
218
+ this.h5h = 0x77e36f73;
219
+ this.h5l = 0x04c48942;
220
+ this.h6h = 0x3f9d85a8;
221
+ this.h6l = 0x6a1d36c8;
222
+ this.h7h = 0x1112e6ad;
223
+ this.h7l = 0x91d692a1;
224
+ } else {
225
+ // 512
226
+ this.h0h = 0x6a09e667;
227
+ this.h0l = 0xf3bcc908;
228
+ this.h1h = 0xbb67ae85;
229
+ this.h1l = 0x84caa73b;
230
+ this.h2h = 0x3c6ef372;
231
+ this.h2l = 0xfe94f82b;
232
+ this.h3h = 0xa54ff53a;
233
+ this.h3l = 0x5f1d36f1;
234
+ this.h4h = 0x510e527f;
235
+ this.h4l = 0xade682d1;
236
+ this.h5h = 0x9b05688c;
237
+ this.h5l = 0x2b3e6c1f;
238
+ this.h6h = 0x1f83d9ab;
239
+ this.h6l = 0xfb41bd6b;
240
+ this.h7h = 0x5be0cd19;
241
+ this.h7l = 0x137e2179;
242
+ }
243
+ this.bits = bits;
244
+
245
+ this.block = this.start = this.bytes = this.hBytes = 0;
246
+ this.finalized = this.hashed = false;
247
+ }
248
+
249
+ Sha512.prototype.update = function (message) {
250
+ if (this.finalized) {
251
+ throw new Error(FINALIZE_ERROR);
252
+ }
253
+ var result = formatMessage(message);
254
+ message = result[0];
255
+ var isString = result[1];
256
+ var code,
257
+ index = 0,
258
+ i,
259
+ length = message.length,
260
+ blocks = this.blocks;
261
+
262
+ while (index < length) {
263
+ if (this.hashed) {
264
+ this.hashed = false;
265
+ blocks[0] = this.block;
266
+ this.block =
267
+ blocks[1] =
268
+ blocks[2] =
269
+ blocks[3] =
270
+ blocks[4] =
271
+ blocks[5] =
272
+ blocks[6] =
273
+ blocks[7] =
274
+ blocks[8] =
275
+ blocks[9] =
276
+ blocks[10] =
277
+ blocks[11] =
278
+ blocks[12] =
279
+ blocks[13] =
280
+ blocks[14] =
281
+ blocks[15] =
282
+ blocks[16] =
283
+ blocks[17] =
284
+ blocks[18] =
285
+ blocks[19] =
286
+ blocks[20] =
287
+ blocks[21] =
288
+ blocks[22] =
289
+ blocks[23] =
290
+ blocks[24] =
291
+ blocks[25] =
292
+ blocks[26] =
293
+ blocks[27] =
294
+ blocks[28] =
295
+ blocks[29] =
296
+ blocks[30] =
297
+ blocks[31] =
298
+ blocks[32] =
299
+ 0;
300
+ }
301
+
302
+ if (isString) {
303
+ for (i = this.start; index < length && i < 128; ++index) {
304
+ code = message.charCodeAt(index);
305
+ if (code < 0x80) {
306
+ blocks[i >>> 2] |= code << SHIFT[i++ & 3];
307
+ } else if (code < 0x800) {
308
+ blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];
309
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
310
+ } else if (code < 0xd800 || code >= 0xe000) {
311
+ blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
312
+ blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
313
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
314
+ } else {
315
+ code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
316
+ blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
317
+ blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
318
+ blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
319
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
320
+ }
321
+ }
322
+ } else {
323
+ for (i = this.start; index < length && i < 128; ++index) {
324
+ blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];
325
+ }
326
+ }
327
+
328
+ this.lastByteIndex = i;
329
+ this.bytes += i - this.start;
330
+ if (i >= 128) {
331
+ this.block = blocks[32];
332
+ this.start = i - 128;
333
+ this.hash();
334
+ this.hashed = true;
335
+ } else {
336
+ this.start = i;
337
+ }
338
+ }
339
+ if (this.bytes > 4294967295) {
340
+ this.hBytes += (this.bytes / 4294967296) << 0;
341
+ this.bytes = this.bytes % 4294967296;
342
+ }
343
+ return this;
344
+ };
345
+
346
+ Sha512.prototype.finalize = function () {
347
+ if (this.finalized) {
348
+ return;
349
+ }
350
+ this.finalized = true;
351
+ var blocks = this.blocks,
352
+ i = this.lastByteIndex;
353
+ blocks[32] = this.block;
354
+ blocks[i >>> 2] |= EXTRA[i & 3];
355
+ this.block = blocks[32];
356
+ if (i >= 112) {
357
+ if (!this.hashed) {
358
+ this.hash();
359
+ }
360
+ blocks[0] = this.block;
361
+ blocks[1] =
362
+ blocks[2] =
363
+ blocks[3] =
364
+ blocks[4] =
365
+ blocks[5] =
366
+ blocks[6] =
367
+ blocks[7] =
368
+ blocks[8] =
369
+ blocks[9] =
370
+ blocks[10] =
371
+ blocks[11] =
372
+ blocks[12] =
373
+ blocks[13] =
374
+ blocks[14] =
375
+ blocks[15] =
376
+ blocks[16] =
377
+ blocks[17] =
378
+ blocks[18] =
379
+ blocks[19] =
380
+ blocks[20] =
381
+ blocks[21] =
382
+ blocks[22] =
383
+ blocks[23] =
384
+ blocks[24] =
385
+ blocks[25] =
386
+ blocks[26] =
387
+ blocks[27] =
388
+ blocks[28] =
389
+ blocks[29] =
390
+ blocks[30] =
391
+ blocks[31] =
392
+ blocks[32] =
393
+ 0;
394
+ }
395
+ blocks[30] = (this.hBytes << 3) | (this.bytes >>> 29);
396
+ blocks[31] = this.bytes << 3;
397
+ this.hash();
398
+ };
399
+
400
+ Sha512.prototype.hash = function () {
401
+ var h0h = this.h0h,
402
+ h0l = this.h0l,
403
+ h1h = this.h1h,
404
+ h1l = this.h1l,
405
+ h2h = this.h2h,
406
+ h2l = this.h2l,
407
+ h3h = this.h3h,
408
+ h3l = this.h3l,
409
+ h4h = this.h4h,
410
+ h4l = this.h4l,
411
+ h5h = this.h5h,
412
+ h5l = this.h5l,
413
+ h6h = this.h6h,
414
+ h6l = this.h6l,
415
+ h7h = this.h7h,
416
+ h7l = this.h7l,
417
+ blocks = this.blocks,
418
+ j,
419
+ s0h,
420
+ s0l,
421
+ s1h,
422
+ s1l,
423
+ c1,
424
+ c2,
425
+ c3,
426
+ c4,
427
+ abh,
428
+ abl,
429
+ dah,
430
+ dal,
431
+ cdh,
432
+ cdl,
433
+ bch,
434
+ bcl,
435
+ majh,
436
+ majl,
437
+ t1h,
438
+ t1l,
439
+ t2h,
440
+ t2l,
441
+ chh,
442
+ chl;
443
+
444
+ for (j = 32; j < 160; j += 2) {
445
+ t1h = blocks[j - 30];
446
+ t1l = blocks[j - 29];
447
+ s0h = ((t1h >>> 1) | (t1l << 31)) ^ ((t1h >>> 8) | (t1l << 24)) ^ (t1h >>> 7);
448
+ s0l = ((t1l >>> 1) | (t1h << 31)) ^ ((t1l >>> 8) | (t1h << 24)) ^ ((t1l >>> 7) | (t1h << 25));
449
+
450
+ t1h = blocks[j - 4];
451
+ t1l = blocks[j - 3];
452
+ s1h = ((t1h >>> 19) | (t1l << 13)) ^ ((t1l >>> 29) | (t1h << 3)) ^ (t1h >>> 6);
453
+ s1l = ((t1l >>> 19) | (t1h << 13)) ^ ((t1h >>> 29) | (t1l << 3)) ^ ((t1l >>> 6) | (t1h << 26));
454
+
455
+ t1h = blocks[j - 32];
456
+ t1l = blocks[j - 31];
457
+ t2h = blocks[j - 14];
458
+ t2l = blocks[j - 13];
459
+
460
+ c1 = (t2l & 0xffff) + (t1l & 0xffff) + (s0l & 0xffff) + (s1l & 0xffff);
461
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (s0l >>> 16) + (s1l >>> 16) + (c1 >>> 16);
462
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (s0h & 0xffff) + (s1h & 0xffff) + (c2 >>> 16);
463
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (s0h >>> 16) + (s1h >>> 16) + (c3 >>> 16);
464
+
465
+ blocks[j] = (c4 << 16) | (c3 & 0xffff);
466
+ blocks[j + 1] = (c2 << 16) | (c1 & 0xffff);
467
+ }
468
+
469
+ var ah = h0h,
470
+ al = h0l,
471
+ bh = h1h,
472
+ bl = h1l,
473
+ ch = h2h,
474
+ cl = h2l,
475
+ dh = h3h,
476
+ dl = h3l,
477
+ eh = h4h,
478
+ el = h4l,
479
+ fh = h5h,
480
+ fl = h5l,
481
+ gh = h6h,
482
+ gl = h6l,
483
+ hh = h7h,
484
+ hl = h7l;
485
+ bch = bh & ch;
486
+ bcl = bl & cl;
487
+ for (j = 0; j < 160; j += 8) {
488
+ s0h = ((ah >>> 28) | (al << 4)) ^ ((al >>> 2) | (ah << 30)) ^ ((al >>> 7) | (ah << 25));
489
+ s0l = ((al >>> 28) | (ah << 4)) ^ ((ah >>> 2) | (al << 30)) ^ ((ah >>> 7) | (al << 25));
490
+
491
+ s1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((el >>> 9) | (eh << 23));
492
+ s1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((eh >>> 9) | (el << 23));
493
+
494
+ abh = ah & bh;
495
+ abl = al & bl;
496
+ majh = abh ^ (ah & ch) ^ bch;
497
+ majl = abl ^ (al & cl) ^ bcl;
498
+
499
+ chh = (eh & fh) ^ (~eh & gh);
500
+ chl = (el & fl) ^ (~el & gl);
501
+
502
+ t1h = blocks[j];
503
+ t1l = blocks[j + 1];
504
+ t2h = K[j];
505
+ t2l = K[j + 1];
506
+
507
+ c1 = (t2l & 0xffff) + (t1l & 0xffff) + (chl & 0xffff) + (s1l & 0xffff) + (hl & 0xffff);
508
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (chl >>> 16) + (s1l >>> 16) + (hl >>> 16) + (c1 >>> 16);
509
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (chh & 0xffff) + (s1h & 0xffff) + (hh & 0xffff) + (c2 >>> 16);
510
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (chh >>> 16) + (s1h >>> 16) + (hh >>> 16) + (c3 >>> 16);
511
+
512
+ t1h = (c4 << 16) | (c3 & 0xffff);
513
+ t1l = (c2 << 16) | (c1 & 0xffff);
514
+
515
+ c1 = (majl & 0xffff) + (s0l & 0xffff);
516
+ c2 = (majl >>> 16) + (s0l >>> 16) + (c1 >>> 16);
517
+ c3 = (majh & 0xffff) + (s0h & 0xffff) + (c2 >>> 16);
518
+ c4 = (majh >>> 16) + (s0h >>> 16) + (c3 >>> 16);
519
+
520
+ t2h = (c4 << 16) | (c3 & 0xffff);
521
+ t2l = (c2 << 16) | (c1 & 0xffff);
522
+
523
+ c1 = (dl & 0xffff) + (t1l & 0xffff);
524
+ c2 = (dl >>> 16) + (t1l >>> 16) + (c1 >>> 16);
525
+ c3 = (dh & 0xffff) + (t1h & 0xffff) + (c2 >>> 16);
526
+ c4 = (dh >>> 16) + (t1h >>> 16) + (c3 >>> 16);
527
+
528
+ hh = (c4 << 16) | (c3 & 0xffff);
529
+ hl = (c2 << 16) | (c1 & 0xffff);
530
+
531
+ c1 = (t2l & 0xffff) + (t1l & 0xffff);
532
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (c1 >>> 16);
533
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (c2 >>> 16);
534
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (c3 >>> 16);
535
+
536
+ dh = (c4 << 16) | (c3 & 0xffff);
537
+ dl = (c2 << 16) | (c1 & 0xffff);
538
+
539
+ s0h = ((dh >>> 28) | (dl << 4)) ^ ((dl >>> 2) | (dh << 30)) ^ ((dl >>> 7) | (dh << 25));
540
+ s0l = ((dl >>> 28) | (dh << 4)) ^ ((dh >>> 2) | (dl << 30)) ^ ((dh >>> 7) | (dl << 25));
541
+
542
+ s1h = ((hh >>> 14) | (hl << 18)) ^ ((hh >>> 18) | (hl << 14)) ^ ((hl >>> 9) | (hh << 23));
543
+ s1l = ((hl >>> 14) | (hh << 18)) ^ ((hl >>> 18) | (hh << 14)) ^ ((hh >>> 9) | (hl << 23));
544
+
545
+ dah = dh & ah;
546
+ dal = dl & al;
547
+ majh = dah ^ (dh & bh) ^ abh;
548
+ majl = dal ^ (dl & bl) ^ abl;
549
+
550
+ chh = (hh & eh) ^ (~hh & fh);
551
+ chl = (hl & el) ^ (~hl & fl);
552
+
553
+ t1h = blocks[j + 2];
554
+ t1l = blocks[j + 3];
555
+ t2h = K[j + 2];
556
+ t2l = K[j + 3];
557
+
558
+ c1 = (t2l & 0xffff) + (t1l & 0xffff) + (chl & 0xffff) + (s1l & 0xffff) + (gl & 0xffff);
559
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (chl >>> 16) + (s1l >>> 16) + (gl >>> 16) + (c1 >>> 16);
560
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (chh & 0xffff) + (s1h & 0xffff) + (gh & 0xffff) + (c2 >>> 16);
561
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (chh >>> 16) + (s1h >>> 16) + (gh >>> 16) + (c3 >>> 16);
562
+
563
+ t1h = (c4 << 16) | (c3 & 0xffff);
564
+ t1l = (c2 << 16) | (c1 & 0xffff);
565
+
566
+ c1 = (majl & 0xffff) + (s0l & 0xffff);
567
+ c2 = (majl >>> 16) + (s0l >>> 16) + (c1 >>> 16);
568
+ c3 = (majh & 0xffff) + (s0h & 0xffff) + (c2 >>> 16);
569
+ c4 = (majh >>> 16) + (s0h >>> 16) + (c3 >>> 16);
570
+
571
+ t2h = (c4 << 16) | (c3 & 0xffff);
572
+ t2l = (c2 << 16) | (c1 & 0xffff);
573
+
574
+ c1 = (cl & 0xffff) + (t1l & 0xffff);
575
+ c2 = (cl >>> 16) + (t1l >>> 16) + (c1 >>> 16);
576
+ c3 = (ch & 0xffff) + (t1h & 0xffff) + (c2 >>> 16);
577
+ c4 = (ch >>> 16) + (t1h >>> 16) + (c3 >>> 16);
578
+
579
+ gh = (c4 << 16) | (c3 & 0xffff);
580
+ gl = (c2 << 16) | (c1 & 0xffff);
581
+
582
+ c1 = (t2l & 0xffff) + (t1l & 0xffff);
583
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (c1 >>> 16);
584
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (c2 >>> 16);
585
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (c3 >>> 16);
586
+
587
+ ch = (c4 << 16) | (c3 & 0xffff);
588
+ cl = (c2 << 16) | (c1 & 0xffff);
589
+
590
+ s0h = ((ch >>> 28) | (cl << 4)) ^ ((cl >>> 2) | (ch << 30)) ^ ((cl >>> 7) | (ch << 25));
591
+ s0l = ((cl >>> 28) | (ch << 4)) ^ ((ch >>> 2) | (cl << 30)) ^ ((ch >>> 7) | (cl << 25));
592
+
593
+ s1h = ((gh >>> 14) | (gl << 18)) ^ ((gh >>> 18) | (gl << 14)) ^ ((gl >>> 9) | (gh << 23));
594
+ s1l = ((gl >>> 14) | (gh << 18)) ^ ((gl >>> 18) | (gh << 14)) ^ ((gh >>> 9) | (gl << 23));
595
+
596
+ cdh = ch & dh;
597
+ cdl = cl & dl;
598
+ majh = cdh ^ (ch & ah) ^ dah;
599
+ majl = cdl ^ (cl & al) ^ dal;
600
+
601
+ chh = (gh & hh) ^ (~gh & eh);
602
+ chl = (gl & hl) ^ (~gl & el);
603
+
604
+ t1h = blocks[j + 4];
605
+ t1l = blocks[j + 5];
606
+ t2h = K[j + 4];
607
+ t2l = K[j + 5];
608
+
609
+ c1 = (t2l & 0xffff) + (t1l & 0xffff) + (chl & 0xffff) + (s1l & 0xffff) + (fl & 0xffff);
610
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (chl >>> 16) + (s1l >>> 16) + (fl >>> 16) + (c1 >>> 16);
611
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (chh & 0xffff) + (s1h & 0xffff) + (fh & 0xffff) + (c2 >>> 16);
612
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (chh >>> 16) + (s1h >>> 16) + (fh >>> 16) + (c3 >>> 16);
613
+
614
+ t1h = (c4 << 16) | (c3 & 0xffff);
615
+ t1l = (c2 << 16) | (c1 & 0xffff);
616
+
617
+ c1 = (majl & 0xffff) + (s0l & 0xffff);
618
+ c2 = (majl >>> 16) + (s0l >>> 16) + (c1 >>> 16);
619
+ c3 = (majh & 0xffff) + (s0h & 0xffff) + (c2 >>> 16);
620
+ c4 = (majh >>> 16) + (s0h >>> 16) + (c3 >>> 16);
621
+
622
+ t2h = (c4 << 16) | (c3 & 0xffff);
623
+ t2l = (c2 << 16) | (c1 & 0xffff);
624
+
625
+ c1 = (bl & 0xffff) + (t1l & 0xffff);
626
+ c2 = (bl >>> 16) + (t1l >>> 16) + (c1 >>> 16);
627
+ c3 = (bh & 0xffff) + (t1h & 0xffff) + (c2 >>> 16);
628
+ c4 = (bh >>> 16) + (t1h >>> 16) + (c3 >>> 16);
629
+
630
+ fh = (c4 << 16) | (c3 & 0xffff);
631
+ fl = (c2 << 16) | (c1 & 0xffff);
632
+
633
+ c1 = (t2l & 0xffff) + (t1l & 0xffff);
634
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (c1 >>> 16);
635
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (c2 >>> 16);
636
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (c3 >>> 16);
637
+
638
+ bh = (c4 << 16) | (c3 & 0xffff);
639
+ bl = (c2 << 16) | (c1 & 0xffff);
640
+
641
+ s0h = ((bh >>> 28) | (bl << 4)) ^ ((bl >>> 2) | (bh << 30)) ^ ((bl >>> 7) | (bh << 25));
642
+ s0l = ((bl >>> 28) | (bh << 4)) ^ ((bh >>> 2) | (bl << 30)) ^ ((bh >>> 7) | (bl << 25));
643
+
644
+ s1h = ((fh >>> 14) | (fl << 18)) ^ ((fh >>> 18) | (fl << 14)) ^ ((fl >>> 9) | (fh << 23));
645
+ s1l = ((fl >>> 14) | (fh << 18)) ^ ((fl >>> 18) | (fh << 14)) ^ ((fh >>> 9) | (fl << 23));
646
+
647
+ bch = bh & ch;
648
+ bcl = bl & cl;
649
+ majh = bch ^ (bh & dh) ^ cdh;
650
+ majl = bcl ^ (bl & dl) ^ cdl;
651
+
652
+ chh = (fh & gh) ^ (~fh & hh);
653
+ chl = (fl & gl) ^ (~fl & hl);
654
+
655
+ t1h = blocks[j + 6];
656
+ t1l = blocks[j + 7];
657
+ t2h = K[j + 6];
658
+ t2l = K[j + 7];
659
+
660
+ c1 = (t2l & 0xffff) + (t1l & 0xffff) + (chl & 0xffff) + (s1l & 0xffff) + (el & 0xffff);
661
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (chl >>> 16) + (s1l >>> 16) + (el >>> 16) + (c1 >>> 16);
662
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (chh & 0xffff) + (s1h & 0xffff) + (eh & 0xffff) + (c2 >>> 16);
663
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (chh >>> 16) + (s1h >>> 16) + (eh >>> 16) + (c3 >>> 16);
664
+
665
+ t1h = (c4 << 16) | (c3 & 0xffff);
666
+ t1l = (c2 << 16) | (c1 & 0xffff);
667
+
668
+ c1 = (majl & 0xffff) + (s0l & 0xffff);
669
+ c2 = (majl >>> 16) + (s0l >>> 16) + (c1 >>> 16);
670
+ c3 = (majh & 0xffff) + (s0h & 0xffff) + (c2 >>> 16);
671
+ c4 = (majh >>> 16) + (s0h >>> 16) + (c3 >>> 16);
672
+
673
+ t2h = (c4 << 16) | (c3 & 0xffff);
674
+ t2l = (c2 << 16) | (c1 & 0xffff);
675
+
676
+ c1 = (al & 0xffff) + (t1l & 0xffff);
677
+ c2 = (al >>> 16) + (t1l >>> 16) + (c1 >>> 16);
678
+ c3 = (ah & 0xffff) + (t1h & 0xffff) + (c2 >>> 16);
679
+ c4 = (ah >>> 16) + (t1h >>> 16) + (c3 >>> 16);
680
+
681
+ eh = (c4 << 16) | (c3 & 0xffff);
682
+ el = (c2 << 16) | (c1 & 0xffff);
683
+
684
+ c1 = (t2l & 0xffff) + (t1l & 0xffff);
685
+ c2 = (t2l >>> 16) + (t1l >>> 16) + (c1 >>> 16);
686
+ c3 = (t2h & 0xffff) + (t1h & 0xffff) + (c2 >>> 16);
687
+ c4 = (t2h >>> 16) + (t1h >>> 16) + (c3 >>> 16);
688
+
689
+ ah = (c4 << 16) | (c3 & 0xffff);
690
+ al = (c2 << 16) | (c1 & 0xffff);
691
+ }
692
+
693
+ c1 = (h0l & 0xffff) + (al & 0xffff);
694
+ c2 = (h0l >>> 16) + (al >>> 16) + (c1 >>> 16);
695
+ c3 = (h0h & 0xffff) + (ah & 0xffff) + (c2 >>> 16);
696
+ c4 = (h0h >>> 16) + (ah >>> 16) + (c3 >>> 16);
697
+
698
+ this.h0h = (c4 << 16) | (c3 & 0xffff);
699
+ this.h0l = (c2 << 16) | (c1 & 0xffff);
700
+
701
+ c1 = (h1l & 0xffff) + (bl & 0xffff);
702
+ c2 = (h1l >>> 16) + (bl >>> 16) + (c1 >>> 16);
703
+ c3 = (h1h & 0xffff) + (bh & 0xffff) + (c2 >>> 16);
704
+ c4 = (h1h >>> 16) + (bh >>> 16) + (c3 >>> 16);
705
+
706
+ this.h1h = (c4 << 16) | (c3 & 0xffff);
707
+ this.h1l = (c2 << 16) | (c1 & 0xffff);
708
+
709
+ c1 = (h2l & 0xffff) + (cl & 0xffff);
710
+ c2 = (h2l >>> 16) + (cl >>> 16) + (c1 >>> 16);
711
+ c3 = (h2h & 0xffff) + (ch & 0xffff) + (c2 >>> 16);
712
+ c4 = (h2h >>> 16) + (ch >>> 16) + (c3 >>> 16);
713
+
714
+ this.h2h = (c4 << 16) | (c3 & 0xffff);
715
+ this.h2l = (c2 << 16) | (c1 & 0xffff);
716
+
717
+ c1 = (h3l & 0xffff) + (dl & 0xffff);
718
+ c2 = (h3l >>> 16) + (dl >>> 16) + (c1 >>> 16);
719
+ c3 = (h3h & 0xffff) + (dh & 0xffff) + (c2 >>> 16);
720
+ c4 = (h3h >>> 16) + (dh >>> 16) + (c3 >>> 16);
721
+
722
+ this.h3h = (c4 << 16) | (c3 & 0xffff);
723
+ this.h3l = (c2 << 16) | (c1 & 0xffff);
724
+
725
+ c1 = (h4l & 0xffff) + (el & 0xffff);
726
+ c2 = (h4l >>> 16) + (el >>> 16) + (c1 >>> 16);
727
+ c3 = (h4h & 0xffff) + (eh & 0xffff) + (c2 >>> 16);
728
+ c4 = (h4h >>> 16) + (eh >>> 16) + (c3 >>> 16);
729
+
730
+ this.h4h = (c4 << 16) | (c3 & 0xffff);
731
+ this.h4l = (c2 << 16) | (c1 & 0xffff);
732
+
733
+ c1 = (h5l & 0xffff) + (fl & 0xffff);
734
+ c2 = (h5l >>> 16) + (fl >>> 16) + (c1 >>> 16);
735
+ c3 = (h5h & 0xffff) + (fh & 0xffff) + (c2 >>> 16);
736
+ c4 = (h5h >>> 16) + (fh >>> 16) + (c3 >>> 16);
737
+
738
+ this.h5h = (c4 << 16) | (c3 & 0xffff);
739
+ this.h5l = (c2 << 16) | (c1 & 0xffff);
740
+
741
+ c1 = (h6l & 0xffff) + (gl & 0xffff);
742
+ c2 = (h6l >>> 16) + (gl >>> 16) + (c1 >>> 16);
743
+ c3 = (h6h & 0xffff) + (gh & 0xffff) + (c2 >>> 16);
744
+ c4 = (h6h >>> 16) + (gh >>> 16) + (c3 >>> 16);
745
+
746
+ this.h6h = (c4 << 16) | (c3 & 0xffff);
747
+ this.h6l = (c2 << 16) | (c1 & 0xffff);
748
+
749
+ c1 = (h7l & 0xffff) + (hl & 0xffff);
750
+ c2 = (h7l >>> 16) + (hl >>> 16) + (c1 >>> 16);
751
+ c3 = (h7h & 0xffff) + (hh & 0xffff) + (c2 >>> 16);
752
+ c4 = (h7h >>> 16) + (hh >>> 16) + (c3 >>> 16);
753
+
754
+ this.h7h = (c4 << 16) | (c3 & 0xffff);
755
+ this.h7l = (c2 << 16) | (c1 & 0xffff);
756
+ };
757
+
758
+ Sha512.prototype.hex = function () {
759
+ this.finalize();
760
+
761
+ var h0h = this.h0h,
762
+ h0l = this.h0l,
763
+ h1h = this.h1h,
764
+ h1l = this.h1l,
765
+ h2h = this.h2h,
766
+ h2l = this.h2l,
767
+ h3h = this.h3h,
768
+ h3l = this.h3l,
769
+ h4h = this.h4h,
770
+ h4l = this.h4l,
771
+ h5h = this.h5h,
772
+ h5l = this.h5l,
773
+ h6h = this.h6h,
774
+ h6l = this.h6l,
775
+ h7h = this.h7h,
776
+ h7l = this.h7l,
777
+ bits = this.bits;
778
+
779
+ var hex =
780
+ HEX_CHARS[(h0h >>> 28) & 0x0f] +
781
+ HEX_CHARS[(h0h >>> 24) & 0x0f] +
782
+ HEX_CHARS[(h0h >>> 20) & 0x0f] +
783
+ HEX_CHARS[(h0h >>> 16) & 0x0f] +
784
+ HEX_CHARS[(h0h >>> 12) & 0x0f] +
785
+ HEX_CHARS[(h0h >>> 8) & 0x0f] +
786
+ HEX_CHARS[(h0h >>> 4) & 0x0f] +
787
+ HEX_CHARS[h0h & 0x0f] +
788
+ HEX_CHARS[(h0l >>> 28) & 0x0f] +
789
+ HEX_CHARS[(h0l >>> 24) & 0x0f] +
790
+ HEX_CHARS[(h0l >>> 20) & 0x0f] +
791
+ HEX_CHARS[(h0l >>> 16) & 0x0f] +
792
+ HEX_CHARS[(h0l >>> 12) & 0x0f] +
793
+ HEX_CHARS[(h0l >>> 8) & 0x0f] +
794
+ HEX_CHARS[(h0l >>> 4) & 0x0f] +
795
+ HEX_CHARS[h0l & 0x0f] +
796
+ HEX_CHARS[(h1h >>> 28) & 0x0f] +
797
+ HEX_CHARS[(h1h >>> 24) & 0x0f] +
798
+ HEX_CHARS[(h1h >>> 20) & 0x0f] +
799
+ HEX_CHARS[(h1h >>> 16) & 0x0f] +
800
+ HEX_CHARS[(h1h >>> 12) & 0x0f] +
801
+ HEX_CHARS[(h1h >>> 8) & 0x0f] +
802
+ HEX_CHARS[(h1h >>> 4) & 0x0f] +
803
+ HEX_CHARS[h1h & 0x0f] +
804
+ HEX_CHARS[(h1l >>> 28) & 0x0f] +
805
+ HEX_CHARS[(h1l >>> 24) & 0x0f] +
806
+ HEX_CHARS[(h1l >>> 20) & 0x0f] +
807
+ HEX_CHARS[(h1l >>> 16) & 0x0f] +
808
+ HEX_CHARS[(h1l >>> 12) & 0x0f] +
809
+ HEX_CHARS[(h1l >>> 8) & 0x0f] +
810
+ HEX_CHARS[(h1l >>> 4) & 0x0f] +
811
+ HEX_CHARS[h1l & 0x0f] +
812
+ HEX_CHARS[(h2h >>> 28) & 0x0f] +
813
+ HEX_CHARS[(h2h >>> 24) & 0x0f] +
814
+ HEX_CHARS[(h2h >>> 20) & 0x0f] +
815
+ HEX_CHARS[(h2h >>> 16) & 0x0f] +
816
+ HEX_CHARS[(h2h >>> 12) & 0x0f] +
817
+ HEX_CHARS[(h2h >>> 8) & 0x0f] +
818
+ HEX_CHARS[(h2h >>> 4) & 0x0f] +
819
+ HEX_CHARS[h2h & 0x0f] +
820
+ HEX_CHARS[(h2l >>> 28) & 0x0f] +
821
+ HEX_CHARS[(h2l >>> 24) & 0x0f] +
822
+ HEX_CHARS[(h2l >>> 20) & 0x0f] +
823
+ HEX_CHARS[(h2l >>> 16) & 0x0f] +
824
+ HEX_CHARS[(h2l >>> 12) & 0x0f] +
825
+ HEX_CHARS[(h2l >>> 8) & 0x0f] +
826
+ HEX_CHARS[(h2l >>> 4) & 0x0f] +
827
+ HEX_CHARS[h2l & 0x0f] +
828
+ HEX_CHARS[(h3h >>> 28) & 0x0f] +
829
+ HEX_CHARS[(h3h >>> 24) & 0x0f] +
830
+ HEX_CHARS[(h3h >>> 20) & 0x0f] +
831
+ HEX_CHARS[(h3h >>> 16) & 0x0f] +
832
+ HEX_CHARS[(h3h >>> 12) & 0x0f] +
833
+ HEX_CHARS[(h3h >>> 8) & 0x0f] +
834
+ HEX_CHARS[(h3h >>> 4) & 0x0f] +
835
+ HEX_CHARS[h3h & 0x0f];
836
+ if (bits >= 256) {
837
+ hex +=
838
+ HEX_CHARS[(h3l >>> 28) & 0x0f] +
839
+ HEX_CHARS[(h3l >>> 24) & 0x0f] +
840
+ HEX_CHARS[(h3l >>> 20) & 0x0f] +
841
+ HEX_CHARS[(h3l >>> 16) & 0x0f] +
842
+ HEX_CHARS[(h3l >>> 12) & 0x0f] +
843
+ HEX_CHARS[(h3l >>> 8) & 0x0f] +
844
+ HEX_CHARS[(h3l >>> 4) & 0x0f] +
845
+ HEX_CHARS[h3l & 0x0f];
846
+ }
847
+ if (bits >= 384) {
848
+ hex +=
849
+ HEX_CHARS[(h4h >>> 28) & 0x0f] +
850
+ HEX_CHARS[(h4h >>> 24) & 0x0f] +
851
+ HEX_CHARS[(h4h >>> 20) & 0x0f] +
852
+ HEX_CHARS[(h4h >>> 16) & 0x0f] +
853
+ HEX_CHARS[(h4h >>> 12) & 0x0f] +
854
+ HEX_CHARS[(h4h >>> 8) & 0x0f] +
855
+ HEX_CHARS[(h4h >>> 4) & 0x0f] +
856
+ HEX_CHARS[h4h & 0x0f] +
857
+ HEX_CHARS[(h4l >>> 28) & 0x0f] +
858
+ HEX_CHARS[(h4l >>> 24) & 0x0f] +
859
+ HEX_CHARS[(h4l >>> 20) & 0x0f] +
860
+ HEX_CHARS[(h4l >>> 16) & 0x0f] +
861
+ HEX_CHARS[(h4l >>> 12) & 0x0f] +
862
+ HEX_CHARS[(h4l >>> 8) & 0x0f] +
863
+ HEX_CHARS[(h4l >>> 4) & 0x0f] +
864
+ HEX_CHARS[h4l & 0x0f] +
865
+ HEX_CHARS[(h5h >>> 28) & 0x0f] +
866
+ HEX_CHARS[(h5h >>> 24) & 0x0f] +
867
+ HEX_CHARS[(h5h >>> 20) & 0x0f] +
868
+ HEX_CHARS[(h5h >>> 16) & 0x0f] +
869
+ HEX_CHARS[(h5h >>> 12) & 0x0f] +
870
+ HEX_CHARS[(h5h >>> 8) & 0x0f] +
871
+ HEX_CHARS[(h5h >>> 4) & 0x0f] +
872
+ HEX_CHARS[h5h & 0x0f] +
873
+ HEX_CHARS[(h5l >>> 28) & 0x0f] +
874
+ HEX_CHARS[(h5l >>> 24) & 0x0f] +
875
+ HEX_CHARS[(h5l >>> 20) & 0x0f] +
876
+ HEX_CHARS[(h5l >>> 16) & 0x0f] +
877
+ HEX_CHARS[(h5l >>> 12) & 0x0f] +
878
+ HEX_CHARS[(h5l >>> 8) & 0x0f] +
879
+ HEX_CHARS[(h5l >>> 4) & 0x0f] +
880
+ HEX_CHARS[h5l & 0x0f];
881
+ }
882
+ if (bits == 512) {
883
+ hex +=
884
+ HEX_CHARS[(h6h >>> 28) & 0x0f] +
885
+ HEX_CHARS[(h6h >>> 24) & 0x0f] +
886
+ HEX_CHARS[(h6h >>> 20) & 0x0f] +
887
+ HEX_CHARS[(h6h >>> 16) & 0x0f] +
888
+ HEX_CHARS[(h6h >>> 12) & 0x0f] +
889
+ HEX_CHARS[(h6h >>> 8) & 0x0f] +
890
+ HEX_CHARS[(h6h >>> 4) & 0x0f] +
891
+ HEX_CHARS[h6h & 0x0f] +
892
+ HEX_CHARS[(h6l >>> 28) & 0x0f] +
893
+ HEX_CHARS[(h6l >>> 24) & 0x0f] +
894
+ HEX_CHARS[(h6l >>> 20) & 0x0f] +
895
+ HEX_CHARS[(h6l >>> 16) & 0x0f] +
896
+ HEX_CHARS[(h6l >>> 12) & 0x0f] +
897
+ HEX_CHARS[(h6l >>> 8) & 0x0f] +
898
+ HEX_CHARS[(h6l >>> 4) & 0x0f] +
899
+ HEX_CHARS[h6l & 0x0f] +
900
+ HEX_CHARS[(h7h >>> 28) & 0x0f] +
901
+ HEX_CHARS[(h7h >>> 24) & 0x0f] +
902
+ HEX_CHARS[(h7h >>> 20) & 0x0f] +
903
+ HEX_CHARS[(h7h >>> 16) & 0x0f] +
904
+ HEX_CHARS[(h7h >>> 12) & 0x0f] +
905
+ HEX_CHARS[(h7h >>> 8) & 0x0f] +
906
+ HEX_CHARS[(h7h >>> 4) & 0x0f] +
907
+ HEX_CHARS[h7h & 0x0f] +
908
+ HEX_CHARS[(h7l >>> 28) & 0x0f] +
909
+ HEX_CHARS[(h7l >>> 24) & 0x0f] +
910
+ HEX_CHARS[(h7l >>> 20) & 0x0f] +
911
+ HEX_CHARS[(h7l >>> 16) & 0x0f] +
912
+ HEX_CHARS[(h7l >>> 12) & 0x0f] +
913
+ HEX_CHARS[(h7l >>> 8) & 0x0f] +
914
+ HEX_CHARS[(h7l >>> 4) & 0x0f] +
915
+ HEX_CHARS[h7l & 0x0f];
916
+ }
917
+ return hex;
918
+ };
919
+
920
+ Sha512.prototype.toString = Sha512.prototype.hex;
921
+
922
+ Sha512.prototype.digest = function () {
923
+ this.finalize();
924
+
925
+ var h0h = this.h0h,
926
+ h0l = this.h0l,
927
+ h1h = this.h1h,
928
+ h1l = this.h1l,
929
+ h2h = this.h2h,
930
+ h2l = this.h2l,
931
+ h3h = this.h3h,
932
+ h3l = this.h3l,
933
+ h4h = this.h4h,
934
+ h4l = this.h4l,
935
+ h5h = this.h5h,
936
+ h5l = this.h5l,
937
+ h6h = this.h6h,
938
+ h6l = this.h6l,
939
+ h7h = this.h7h,
940
+ h7l = this.h7l,
941
+ bits = this.bits;
942
+
943
+ var arr = [
944
+ (h0h >>> 24) & 0xff,
945
+ (h0h >>> 16) & 0xff,
946
+ (h0h >>> 8) & 0xff,
947
+ h0h & 0xff,
948
+ (h0l >>> 24) & 0xff,
949
+ (h0l >>> 16) & 0xff,
950
+ (h0l >>> 8) & 0xff,
951
+ h0l & 0xff,
952
+ (h1h >>> 24) & 0xff,
953
+ (h1h >>> 16) & 0xff,
954
+ (h1h >>> 8) & 0xff,
955
+ h1h & 0xff,
956
+ (h1l >>> 24) & 0xff,
957
+ (h1l >>> 16) & 0xff,
958
+ (h1l >>> 8) & 0xff,
959
+ h1l & 0xff,
960
+ (h2h >>> 24) & 0xff,
961
+ (h2h >>> 16) & 0xff,
962
+ (h2h >>> 8) & 0xff,
963
+ h2h & 0xff,
964
+ (h2l >>> 24) & 0xff,
965
+ (h2l >>> 16) & 0xff,
966
+ (h2l >>> 8) & 0xff,
967
+ h2l & 0xff,
968
+ (h3h >>> 24) & 0xff,
969
+ (h3h >>> 16) & 0xff,
970
+ (h3h >>> 8) & 0xff,
971
+ h3h & 0xff,
972
+ ];
973
+
974
+ if (bits >= 256) {
975
+ arr.push((h3l >>> 24) & 0xff, (h3l >>> 16) & 0xff, (h3l >>> 8) & 0xff, h3l & 0xff);
976
+ }
977
+ if (bits >= 384) {
978
+ arr.push(
979
+ (h4h >>> 24) & 0xff,
980
+ (h4h >>> 16) & 0xff,
981
+ (h4h >>> 8) & 0xff,
982
+ h4h & 0xff,
983
+ (h4l >>> 24) & 0xff,
984
+ (h4l >>> 16) & 0xff,
985
+ (h4l >>> 8) & 0xff,
986
+ h4l & 0xff,
987
+ (h5h >>> 24) & 0xff,
988
+ (h5h >>> 16) & 0xff,
989
+ (h5h >>> 8) & 0xff,
990
+ h5h & 0xff,
991
+ (h5l >>> 24) & 0xff,
992
+ (h5l >>> 16) & 0xff,
993
+ (h5l >>> 8) & 0xff,
994
+ h5l & 0xff,
995
+ );
996
+ }
997
+ if (bits == 512) {
998
+ arr.push(
999
+ (h6h >>> 24) & 0xff,
1000
+ (h6h >>> 16) & 0xff,
1001
+ (h6h >>> 8) & 0xff,
1002
+ h6h & 0xff,
1003
+ (h6l >>> 24) & 0xff,
1004
+ (h6l >>> 16) & 0xff,
1005
+ (h6l >>> 8) & 0xff,
1006
+ h6l & 0xff,
1007
+ (h7h >>> 24) & 0xff,
1008
+ (h7h >>> 16) & 0xff,
1009
+ (h7h >>> 8) & 0xff,
1010
+ h7h & 0xff,
1011
+ (h7l >>> 24) & 0xff,
1012
+ (h7l >>> 16) & 0xff,
1013
+ (h7l >>> 8) & 0xff,
1014
+ h7l & 0xff,
1015
+ );
1016
+ }
1017
+ return arr;
1018
+ };
1019
+
1020
+ Sha512.prototype.array = Sha512.prototype.digest;
1021
+
1022
+ Sha512.prototype.arrayBuffer = function () {
1023
+ this.finalize();
1024
+
1025
+ var bits = this.bits;
1026
+ var buffer = new ArrayBuffer(bits / 8);
1027
+ var dataView = new DataView(buffer);
1028
+ dataView.setUint32(0, this.h0h);
1029
+ dataView.setUint32(4, this.h0l);
1030
+ dataView.setUint32(8, this.h1h);
1031
+ dataView.setUint32(12, this.h1l);
1032
+ dataView.setUint32(16, this.h2h);
1033
+ dataView.setUint32(20, this.h2l);
1034
+ dataView.setUint32(24, this.h3h);
1035
+
1036
+ if (bits >= 256) {
1037
+ dataView.setUint32(28, this.h3l);
1038
+ }
1039
+ if (bits >= 384) {
1040
+ dataView.setUint32(32, this.h4h);
1041
+ dataView.setUint32(36, this.h4l);
1042
+ dataView.setUint32(40, this.h5h);
1043
+ dataView.setUint32(44, this.h5l);
1044
+ }
1045
+ if (bits == 512) {
1046
+ dataView.setUint32(48, this.h6h);
1047
+ dataView.setUint32(52, this.h6l);
1048
+ dataView.setUint32(56, this.h7h);
1049
+ dataView.setUint32(60, this.h7l);
1050
+ }
1051
+ return buffer;
1052
+ };
1053
+
1054
+ Sha512.prototype.clone = function () {
1055
+ var hash = new Sha512(this.bits, false);
1056
+ this.copyTo(hash);
1057
+ return hash;
1058
+ };
1059
+
1060
+ Sha512.prototype.copyTo = function (hash) {
1061
+ var i = 0,
1062
+ attrs = [
1063
+ "h0h",
1064
+ "h0l",
1065
+ "h1h",
1066
+ "h1l",
1067
+ "h2h",
1068
+ "h2l",
1069
+ "h3h",
1070
+ "h3l",
1071
+ "h4h",
1072
+ "h4l",
1073
+ "h5h",
1074
+ "h5l",
1075
+ "h6h",
1076
+ "h6l",
1077
+ "h7h",
1078
+ "h7l",
1079
+ "start",
1080
+ "bytes",
1081
+ "hBytes",
1082
+ "finalized",
1083
+ "hashed",
1084
+ "lastByteIndex",
1085
+ ];
1086
+ for (i = 0; i < attrs.length; ++i) {
1087
+ hash[attrs[i]] = this[attrs[i]];
1088
+ }
1089
+ for (i = 0; i < this.blocks.length; ++i) {
1090
+ hash.blocks[i] = this.blocks[i];
1091
+ }
1092
+ };
1093
+
1094
+ function HmacSha512(key, bits, sharedMemory) {
1095
+ var i,
1096
+ result = formatMessage(key);
1097
+ key = result[0];
1098
+ if (result[1]) {
1099
+ var bytes = [],
1100
+ length = key.length,
1101
+ index = 0,
1102
+ code;
1103
+ for (var i = 0; i < length; ++i) {
1104
+ code = key.charCodeAt(i);
1105
+ if (code < 0x80) {
1106
+ bytes[index++] = code;
1107
+ } else if (code < 0x800) {
1108
+ bytes[index++] = 0xc0 | (code >>> 6);
1109
+ bytes[index++] = 0x80 | (code & 0x3f);
1110
+ } else if (code < 0xd800 || code >= 0xe000) {
1111
+ bytes[index++] = 0xe0 | (code >>> 12);
1112
+ bytes[index++] = 0x80 | ((code >>> 6) & 0x3f);
1113
+ bytes[index++] = 0x80 | (code & 0x3f);
1114
+ } else {
1115
+ code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
1116
+ bytes[index++] = 0xf0 | (code >>> 18);
1117
+ bytes[index++] = 0x80 | ((code >>> 12) & 0x3f);
1118
+ bytes[index++] = 0x80 | ((code >>> 6) & 0x3f);
1119
+ bytes[index++] = 0x80 | (code & 0x3f);
1120
+ }
1121
+ }
1122
+ key = bytes;
1123
+ }
1124
+
1125
+ if (key.length > 128) {
1126
+ key = new Sha512(bits, true).update(key).array();
1127
+ }
1128
+
1129
+ var oKeyPad = [],
1130
+ iKeyPad = [];
1131
+ for (var i = 0; i < 128; ++i) {
1132
+ var b = key[i] || 0;
1133
+ oKeyPad[i] = 0x5c ^ b;
1134
+ iKeyPad[i] = 0x36 ^ b;
1135
+ }
1136
+
1137
+ Sha512.call(this, bits, sharedMemory);
1138
+
1139
+ this.update(iKeyPad);
1140
+ this.oKeyPad = oKeyPad;
1141
+ this.inner = true;
1142
+ this.sharedMemory = sharedMemory;
1143
+ }
1144
+
1145
+ HmacSha512.prototype = new Sha512();
1146
+
1147
+ HmacSha512.prototype.finalize = function () {
1148
+ Sha512.prototype.finalize.call(this);
1149
+ if (this.inner) {
1150
+ this.inner = false;
1151
+ var innerHash = this.array();
1152
+ Sha512.call(this, this.bits, this.sharedMemory);
1153
+ this.update(this.oKeyPad);
1154
+ this.update(innerHash);
1155
+ Sha512.prototype.finalize.call(this);
1156
+ }
1157
+ };
1158
+
1159
+ HmacSha512.prototype.clone = function () {
1160
+ var hash = new HmacSha512([], this.bits, false);
1161
+ this.copyTo(hash);
1162
+ hash.inner = this.inner;
1163
+ for (var i = 0; i < this.oKeyPad.length; ++i) {
1164
+ hash.oKeyPad[i] = this.oKeyPad[i];
1165
+ }
1166
+ return hash;
1167
+ };
1168
+
1169
+ /* 以下是内部实现需要的es模块化导出方法 */
1170
+ const sha512 = createMethod(512);
1171
+ const sha384 = createMethod(384);
1172
+ const sha512_256 = createMethod(256);
1173
+ const sha512_224 = createMethod(224);
1174
+ const sha512_hmac = createHmacMethod(512);
1175
+ const sha384_hmac = createHmacMethod(384);
1176
+ const sha512_256_hmac = createHmacMethod(256);
1177
+ const sha512_224_hmac = createHmacMethod(224);
1178
+
1179
+ exports.sha384 = sha384;
1180
+ exports.sha384_hmac = sha384_hmac;
1181
+ exports.sha512 = sha512;
1182
+ exports.sha512_224 = sha512_224;
1183
+ exports.sha512_224_hmac = sha512_224_hmac;
1184
+ exports.sha512_256 = sha512_256;
1185
+ exports.sha512_256_hmac = sha512_256_hmac;
1186
+ exports.sha512_hmac = sha512_hmac;