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