1 | // Type definitions for crypto-js 4.1
|
2 | // Project: https://github.com/brix/crypto-js
|
3 | // Definitions by: Michael Zabka <https://github.com/misak113>
|
4 | // Max Lysenko <https://github.com/maximlysenko>
|
5 | // Brendan Early <https://github.com/mymindstorm>
|
6 | // Doma <https://github.com/SevenOutman>
|
7 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
8 |
|
9 | export = CryptoJS;
|
10 |
|
11 | type WordArray = CryptoJS.lib.WordArray;
|
12 | type CipherParams = CryptoJS.lib.CipherParams;
|
13 | type X64Word = CryptoJS.x64.Word;
|
14 |
|
15 | /**
|
16 | * Encoding strategy.
|
17 | */
|
18 | interface Encoder {
|
19 | /**
|
20 | * Converts a word array to a hex string.
|
21 | *
|
22 | * @param wordArray The word array.
|
23 | *
|
24 | * @return The hex string.
|
25 | *
|
26 | * @example
|
27 | *
|
28 | * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
29 | */
|
30 | stringify(wordArray: WordArray): string;
|
31 | /**
|
32 | * Converts a hex string to a word array.
|
33 | *
|
34 | * @param hexStr The hex string.
|
35 | *
|
36 | * @return The word array.
|
37 | *
|
38 | * @example
|
39 | *
|
40 | * var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
41 | */
|
42 | parse(str: string): WordArray;
|
43 | }
|
44 |
|
45 | /**
|
46 | * Abstract buffered block algorithm template.
|
47 | *
|
48 | * The property blockSize must be implemented in a concrete subtype.
|
49 | */
|
50 | interface BufferedBlockAlgorithm {
|
51 | /**
|
52 | * The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
53 | */
|
54 | _minBufferSize: number;
|
55 | /**
|
56 | * Resets this block algorithm's data buffer to its initial state.
|
57 | *
|
58 | * @example
|
59 | *
|
60 | * bufferedBlockAlgorithm.reset();
|
61 | */
|
62 | reset(): void;
|
63 | /**
|
64 | * Adds new data to this block algorithm's buffer.
|
65 | *
|
66 | * @param data The data to append. Strings are converted to a WordArray using UTF-8.
|
67 | *
|
68 | * @example
|
69 | *
|
70 | * bufferedBlockAlgorithm._append('data');
|
71 | * bufferedBlockAlgorithm._append(wordArray);
|
72 | */
|
73 | _append(data: WordArray | string): void;
|
74 | /**
|
75 | * Processes available data blocks.
|
76 | *
|
77 | * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
78 | *
|
79 | * @param doFlush Whether all blocks and partial blocks should be processed.
|
80 | *
|
81 | * @return The processed data.
|
82 | *
|
83 | * @example
|
84 | *
|
85 | * var processedData = bufferedBlockAlgorithm._process();
|
86 | * var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
87 | */
|
88 | _process(doFlush?: boolean): WordArray;
|
89 | /**
|
90 | * Creates a copy of this object.
|
91 | *
|
92 | * @return The clone.
|
93 | *
|
94 | * @example
|
95 | *
|
96 | * var clone = bufferedBlockAlgorithm.clone();
|
97 | */
|
98 | clone(): BufferedBlockAlgorithm;
|
99 | }
|
100 |
|
101 | /**
|
102 | * Abstract hasher template.
|
103 | */
|
104 | interface Hasher {
|
105 | /**
|
106 | * The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
|
107 | */
|
108 | blockSize: number;
|
109 | /**
|
110 | * Resets this hasher to its initial state.
|
111 | *
|
112 | * @example
|
113 | *
|
114 | * hasher.reset();
|
115 | */
|
116 | reset(): void;
|
117 | /**
|
118 | * Updates this hasher with a message.
|
119 | *
|
120 | * @param messageUpdate The message to append.
|
121 | *
|
122 | * @return This hasher.
|
123 | *
|
124 | * @example
|
125 | *
|
126 | * hasher.update('message');
|
127 | * hasher.update(wordArray);
|
128 | */
|
129 | update(messageUpdate: WordArray | string): this;
|
130 | /**
|
131 | * Finalizes the hash computation.
|
132 | * Note that the finalize operation is effectively a destructive, read-once operation.
|
133 | *
|
134 | * @param messageUpdate (Optional) A final message update.
|
135 | *
|
136 | * @return The hash.
|
137 | *
|
138 | * @example
|
139 | *
|
140 | * var hash = hasher.finalize();
|
141 | * var hash = hasher.finalize('message');
|
142 | * var hash = hasher.finalize(wordArray);
|
143 | */
|
144 | finalize(messageUpdate?: WordArray | string): WordArray;
|
145 | }
|
146 |
|
147 | interface HasherStatic {
|
148 | /**
|
149 | * Initializes a newly created hasher.
|
150 | *
|
151 | * @param cfg (Optional) The configuration options to use for this hash computation.
|
152 | *
|
153 | * @example
|
154 | *
|
155 | * var hasher = CryptoJS.algo.SHA256.create();
|
156 | */
|
157 | create(cfg?: object): Hasher;
|
158 | }
|
159 |
|
160 | interface HasherHelper {
|
161 | (message: WordArray | string, cfg?: object): WordArray;
|
162 | }
|
163 |
|
164 | interface HmacHasherHelper {
|
165 | (message: WordArray | string, key: WordArray | string): WordArray;
|
166 | }
|
167 |
|
168 | /**
|
169 | * Abstract base cipher template.
|
170 | */
|
171 | interface Cipher {
|
172 | /**
|
173 | * This cipher's key size. Default: 4 (128 bits)
|
174 | */
|
175 | keySize: number;
|
176 | /**
|
177 | * This cipher's IV size. Default: 4 (128 bits)
|
178 | */
|
179 | ivSize: number;
|
180 | /**
|
181 | * A constant representing encryption mode.
|
182 | */
|
183 | readonly _ENC_XFORM_MODE: number;
|
184 | /**
|
185 | * A constant representing decryption mode.
|
186 | */
|
187 | readonly _DEV_XFORM_MODE: number;
|
188 |
|
189 | /**
|
190 | * Resets this cipher to its initial state.
|
191 | *
|
192 | * @example
|
193 | *
|
194 | * cipher.reset();
|
195 | */
|
196 | reset(): void;
|
197 |
|
198 | /**
|
199 | * Adds data to be encrypted or decrypted.
|
200 | *
|
201 | * @param dataUpdate The data to encrypt or decrypt.
|
202 | *
|
203 | * @return The data after processing.
|
204 | *
|
205 | * @example
|
206 | *
|
207 | * var encrypted = cipher.process('data');
|
208 | * var encrypted = cipher.process(wordArray);
|
209 | */
|
210 | process(dataUpdate: WordArray | string): WordArray;
|
211 |
|
212 | /**
|
213 | * Finalizes the encryption or decryption process.
|
214 | * Note that the finalize operation is effectively a destructive, read-once operation.
|
215 | *
|
216 | * @param dataUpdate The final data to encrypt or decrypt.
|
217 | *
|
218 | * @return The data after final processing.
|
219 | *
|
220 | * @example
|
221 | *
|
222 | * var encrypted = cipher.finalize();
|
223 | * var encrypted = cipher.finalize('data');
|
224 | * var encrypted = cipher.finalize(wordArray);
|
225 | */
|
226 | finalize(dataUpdate?: WordArray | string): WordArray;
|
227 | }
|
228 |
|
229 | interface CipherStatic {
|
230 | /**
|
231 | * Creates this cipher in encryption mode.
|
232 | *
|
233 | * @param key The key.
|
234 | * @param cfg (Optional) The configuration options to use for this operation.
|
235 | *
|
236 | * @return A cipher instance.
|
237 | *
|
238 | * @example
|
239 | *
|
240 | * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
|
241 | */
|
242 | createEncryptor(key: WordArray, cfg?: CipherOption): Cipher;
|
243 |
|
244 | /**
|
245 | * Creates this cipher in decryption mode.
|
246 | *
|
247 | * @param key The key.
|
248 | * @param cfg (Optional) The configuration options to use for this operation.
|
249 | *
|
250 | * @return A cipher instance.
|
251 | *
|
252 | * @example
|
253 | *
|
254 | * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
|
255 | */
|
256 | createDecryptor(key: WordArray, cfg?: CipherOption): Cipher;
|
257 |
|
258 | /**
|
259 | * Initializes a newly created cipher.
|
260 | *
|
261 | * @param xformMode Either the encryption or decryption transormation mode constant.
|
262 | * @param key The key.
|
263 | * @param cfg (Optional) The configuration options to use for this operation.
|
264 | *
|
265 | * @example
|
266 | *
|
267 | * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
|
268 | */
|
269 | create(xformMode: number, key: WordArray, cfg?: CipherOption): Cipher;
|
270 | }
|
271 |
|
272 | interface CipherHelper {
|
273 | encrypt(message: WordArray | string, key: WordArray | string, cfg?: CipherOption): CipherParams;
|
274 | decrypt(ciphertext: CipherParams | string, key: WordArray | string, cfg?: CipherOption): WordArray;
|
275 | }
|
276 |
|
277 | /**
|
278 | * Configuration options.
|
279 | */
|
280 | interface CipherOption {
|
281 | /**
|
282 | * The IV to use for this operation.
|
283 | */
|
284 | iv?: WordArray | undefined;
|
285 | format?: Format | undefined;
|
286 | [key: string]: any;
|
287 | }
|
288 |
|
289 | interface Mode {
|
290 | /**
|
291 | * Processes the data block at offset.
|
292 | *
|
293 | * @param words The data words to operate on.
|
294 | * @param offset The offset where the block starts.
|
295 | *
|
296 | * @example
|
297 | *
|
298 | * mode.processBlock(data.words, offset);
|
299 | */
|
300 | processBlock(words: number[], offset: number): void;
|
301 | }
|
302 |
|
303 | interface ModeStatic {
|
304 | /**
|
305 | * Initializes a newly created mode.
|
306 | *
|
307 | * @param cipher A block cipher instance.
|
308 | * @param iv The IV words.
|
309 | *
|
310 | * @example
|
311 | *
|
312 | * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
|
313 | */
|
314 | create(cipher: Cipher, iv: number[]): Mode;
|
315 | }
|
316 |
|
317 | /**
|
318 | * Abstract base block cipher mode template.
|
319 | */
|
320 | interface BlockCipherMode {
|
321 | Encryptor: ModeStatic;
|
322 | Decryptor: ModeStatic;
|
323 | /**
|
324 | * Creates this mode for encryption.
|
325 | *
|
326 | * @param cipher A block cipher instance.
|
327 | * @param iv The IV words.
|
328 | *
|
329 | * @example
|
330 | *
|
331 | * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
|
332 | */
|
333 | createEncryptor(cipher: Cipher, iv: number[]): Mode;
|
334 |
|
335 | /**
|
336 | * Creates this mode for decryption.
|
337 | *
|
338 | * @param cipher A block cipher instance.
|
339 | * @param iv The IV words.
|
340 | *
|
341 | * @example
|
342 | *
|
343 | * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
|
344 | */
|
345 | createDecryptor(cipher: Cipher, iv: number[]): Mode;
|
346 | }
|
347 |
|
348 | /**
|
349 | * Abstract base block cipher mode template.
|
350 | */
|
351 | interface BlockCipherMode {
|
352 | /**
|
353 | * Creates this mode for encryption.
|
354 | *
|
355 | * @param cipher A block cipher instance.
|
356 | * @param iv The IV words.
|
357 | *
|
358 | * @example
|
359 | *
|
360 | * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
|
361 | */
|
362 | createEncryptor(cipher: Cipher): Mode;
|
363 | }
|
364 |
|
365 | /**
|
366 | * Padding strategy.
|
367 | */
|
368 | interface Padding {
|
369 | /**
|
370 | * Pads data using the algorithm defined in PKCS #5/7.
|
371 | *
|
372 | * @param data The data to pad.
|
373 | * @param blockSize The multiple that the data should be padded to.
|
374 | *
|
375 | * @example
|
376 | *
|
377 | * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
|
378 | */
|
379 | pad(data: WordArray, blockSize: number): void;
|
380 |
|
381 | /**
|
382 | * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
|
383 | *
|
384 | * @param data The data to unpad.
|
385 | *
|
386 | * @example
|
387 | *
|
388 | * CryptoJS.pad.Pkcs7.unpad(wordArray);
|
389 | */
|
390 | unpad(data: WordArray): void;
|
391 | }
|
392 |
|
393 | /**
|
394 | * Abstract base block cipher template.
|
395 | */
|
396 | interface BlockCipher {
|
397 | /**
|
398 | * The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
|
399 | */
|
400 | blockSize: number;
|
401 | }
|
402 |
|
403 | /**
|
404 | * Configuration options.
|
405 | */
|
406 | interface BlockCipherOption {
|
407 | /**
|
408 | * The block mode to use. Default: CBC
|
409 | */
|
410 | mode: Mode;
|
411 | /**
|
412 | * The padding strategy to use. Default: Pkcs7
|
413 | */
|
414 | padding: Padding;
|
415 | }
|
416 | /**
|
417 | * Formatting strategy.
|
418 | */
|
419 | interface Format {
|
420 | /**
|
421 | * Converts a cipher params object to an OpenSSL-compatible string.
|
422 | *
|
423 | * @param cipherParams The cipher params object.
|
424 | *
|
425 | * @return The OpenSSL-compatible string.
|
426 | *
|
427 | * @example
|
428 | *
|
429 | * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
|
430 | */
|
431 | stringify(cipherParams: CipherParams): string;
|
432 |
|
433 | /**
|
434 | * Converts an OpenSSL-compatible string to a cipher params object.
|
435 | *
|
436 | * @param openSSLStr The OpenSSL-compatible string.
|
437 | *
|
438 | * @return The cipher params object.
|
439 | *
|
440 | * @example
|
441 | *
|
442 | * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
|
443 | */
|
444 | parse(str: string): CipherParams;
|
445 | }
|
446 |
|
447 | /**
|
448 | * An array of 64-bit words.
|
449 | */
|
450 | interface X64WordArray {
|
451 | /**
|
452 | * The array of CryptoJS.x64.Word objects.
|
453 | */
|
454 | words: number[];
|
455 | /**
|
456 | * The number of significant bytes in this word array.
|
457 | */
|
458 | sigBytes: number;
|
459 |
|
460 | /**
|
461 | * Converts this 64-bit word array to a 32-bit word array.
|
462 | *
|
463 | * @return This word array's data as a 32-bit word array.
|
464 | *
|
465 | * @example
|
466 | *
|
467 | * var x32WordArray = x64WordArray.toX32();
|
468 | */
|
469 | toX32(): WordArray;
|
470 |
|
471 | /**
|
472 | * Creates a copy of this word array.
|
473 | *
|
474 | * @return The clone.
|
475 | *
|
476 | * @example
|
477 | *
|
478 | * var clone = x64WordArray.clone();
|
479 | */
|
480 | clone(): X64WordArray;
|
481 | }
|
482 |
|
483 | /**
|
484 | * Base object for prototypal inheritance.
|
485 | */
|
486 | interface Base {
|
487 | /**
|
488 | * Creates a copy of this object.
|
489 | *
|
490 | * @return The clone.
|
491 | *
|
492 | * @example
|
493 | *
|
494 | * var clone = instance.clone();
|
495 | */
|
496 | clone(): this;
|
497 | }
|
498 |
|
499 | /**
|
500 | * Configuration options.
|
501 | */
|
502 | interface KDFOption {
|
503 | /**
|
504 | * The key size in words to generate.
|
505 | */
|
506 | keySize?: number | undefined;
|
507 | /**
|
508 | * The hasher to use.
|
509 | */
|
510 | hasher?: HasherStatic | undefined;
|
511 | /**
|
512 | * The number of iterations to perform.
|
513 | */
|
514 | iterations?: number | undefined;
|
515 | }
|
516 |
|
517 | declare global {
|
518 | namespace CryptoJS {
|
519 | /**
|
520 | * Library namespace.
|
521 | */
|
522 | export namespace lib {
|
523 | /**
|
524 | * Base object for prototypal inheritance.
|
525 | */
|
526 | const Base: {
|
527 | /**
|
528 | * Creates a new object that inherits from this object.
|
529 | *
|
530 | * @param overrides Properties to copy into the new object.
|
531 | *
|
532 | * @return The new object.
|
533 | *
|
534 | * @example
|
535 | *
|
536 | * var MyType = CryptoJS.lib.Base.extend({
|
537 | * field: 'value',
|
538 | *
|
539 | * method: function () {
|
540 | * }
|
541 | * });
|
542 | */
|
543 | extend(overrides: object): any;
|
544 |
|
545 | /**
|
546 | * Extends this object and runs the init method.
|
547 | * Arguments to create() will be passed to init().
|
548 | *
|
549 | * @return The new object.
|
550 | *
|
551 | * @example
|
552 | *
|
553 | * var instance = MyType.create();
|
554 | */
|
555 | create(...args: any[]): any;
|
556 |
|
557 | /**
|
558 | * Copies properties into this object.
|
559 | *
|
560 | * @param properties The properties to mix in.
|
561 | *
|
562 | * @example
|
563 | *
|
564 | * MyType.mixIn({
|
565 | * field: 'value'
|
566 | * });
|
567 | */
|
568 | mixIn(properties: object): any;
|
569 | };
|
570 |
|
571 | /**
|
572 | * An array of 32-bit words.
|
573 | */
|
574 | interface WordArray {
|
575 | /**
|
576 | * The array of 32-bit words.
|
577 | */
|
578 | words: number[];
|
579 | /**
|
580 | * The number of significant bytes in this word array.
|
581 | */
|
582 | sigBytes: number;
|
583 | /**
|
584 | * Converts this word array to a string.
|
585 | *
|
586 | * @param encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
587 | *
|
588 | * @return The stringified word array.
|
589 | *
|
590 | * @example
|
591 | *
|
592 | * var string = wordArray + '';
|
593 | * var string = wordArray.toString();
|
594 | * var string = wordArray.toString(CryptoJS.enc.Utf8);
|
595 | */
|
596 | toString(encoder?: Encoder): string;
|
597 |
|
598 | /**
|
599 | * Concatenates a word array to this word array.
|
600 | *
|
601 | * @param wordArray The word array to append.
|
602 | *
|
603 | * @return This word array.
|
604 | *
|
605 | * @example
|
606 | *
|
607 | * wordArray1.concat(wordArray2);
|
608 | */
|
609 | concat(wordArray: WordArray): this;
|
610 |
|
611 | /**
|
612 | * Removes insignificant bits.
|
613 | *
|
614 | * @example
|
615 | *
|
616 | * wordArray.clamp();
|
617 | */
|
618 | clamp(): void;
|
619 |
|
620 | /**
|
621 | * Creates a copy of this word array.
|
622 | *
|
623 | * @return The clone.
|
624 | *
|
625 | * @example
|
626 | *
|
627 | * var clone = wordArray.clone();
|
628 | */
|
629 | clone(): WordArray;
|
630 | }
|
631 | const WordArray: {
|
632 | /**
|
633 | * Initializes a newly created word array.
|
634 | *
|
635 | * @param words (Optional) An array of 32-bit words.
|
636 | * @param sigBytes (Optional) The number of significant bytes in the words.
|
637 | *
|
638 | * @example
|
639 | *
|
640 | * var wordArray = CryptoJS.lib.WordArray.create();
|
641 | * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
642 | * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
643 | */
|
644 | create(words?: number[], sigBytes?: number): WordArray;
|
645 | /**
|
646 | * Creates a word array filled with random bytes.
|
647 | *
|
648 | * @param nBytes The number of random bytes to generate.
|
649 | *
|
650 | * @return The random word array.
|
651 | *
|
652 | * @example
|
653 | *
|
654 | * var wordArray = CryptoJS.lib.WordArray.random(16);
|
655 | */
|
656 | random(nBytes: number): WordArray;
|
657 | };
|
658 |
|
659 | const BufferedBlockAlgorithm: any;
|
660 |
|
661 | const Hasher: {
|
662 | /**
|
663 | * Creates a shortcut function to a hasher's object interface.
|
664 | *
|
665 | * @param hasher The hasher to create a helper for.
|
666 | *
|
667 | * @return The shortcut function.
|
668 | *
|
669 | * @example
|
670 | *
|
671 | * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
672 | */
|
673 | _createHelper(hasher: HasherStatic): HasherHelper;
|
674 | /**
|
675 | * Creates a shortcut function to the HMAC's object interface.
|
676 | *
|
677 | * @param hasher The hasher to use in this HMAC helper.
|
678 | *
|
679 | * @return The shortcut function.
|
680 | *
|
681 | * @example
|
682 | *
|
683 | * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
684 | */
|
685 | _createHmacHelper(hasher: HasherStatic): HmacHasherHelper;
|
686 | };
|
687 |
|
688 | const Cipher: {
|
689 | /**
|
690 | * Creates shortcut functions to a cipher's object interface.
|
691 | *
|
692 | * @param cipher The cipher to create a helper for.
|
693 | *
|
694 | * @return An object with encrypt and decrypt shortcut functions.
|
695 | *
|
696 | * @example
|
697 | *
|
698 | * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
|
699 | */
|
700 | _createHelper(cipher: Cipher): CipherHelper;
|
701 | };
|
702 |
|
703 | /**
|
704 | * A collection of cipher parameters.
|
705 | */
|
706 | interface CipherParams {
|
707 | /**
|
708 | * The raw ciphertext.
|
709 | */
|
710 | ciphertext: WordArray;
|
711 | /**
|
712 | * The key to this ciphertext.
|
713 | */
|
714 | key: WordArray;
|
715 | /**
|
716 | * The IV used in the ciphering operation.
|
717 | */
|
718 | iv: WordArray;
|
719 | /**
|
720 | * The salt used with a key derivation function.
|
721 | */
|
722 | salt: WordArray;
|
723 | /**
|
724 | * The cipher algorithm.
|
725 | */
|
726 | algorithm: CipherStatic;
|
727 | /**
|
728 | * The block mode used in the ciphering operation.
|
729 | */
|
730 | mode: Mode;
|
731 | /**
|
732 | * The padding scheme used in the ciphering operation.
|
733 | */
|
734 | padding: Padding;
|
735 | /**
|
736 | * The block size of the cipher.
|
737 | */
|
738 | blockSize: number;
|
739 | /**
|
740 | * The default formatting strategy to convert this cipher params object to a string.
|
741 | */
|
742 | formatter: Format;
|
743 | /**
|
744 | * Converts this cipher params object to a string.
|
745 | *
|
746 | * @param formatter (Optional) The formatting strategy to use.
|
747 | *
|
748 | * @return The stringified cipher params.
|
749 | *
|
750 | * @throws Error If neither the formatter nor the default formatter is set.
|
751 | *
|
752 | * @example
|
753 | *
|
754 | * var string = cipherParams + '';
|
755 | * var string = cipherParams.toString();
|
756 | * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
|
757 | */
|
758 | toString(formatter?: Format): string;
|
759 | }
|
760 | const CipherParams: {
|
761 | /**
|
762 | * Initializes a newly created cipher params object.
|
763 | *
|
764 | * @param cipherParams An object with any of the possible cipher parameters.
|
765 | *
|
766 | * @example
|
767 | *
|
768 | * var cipherParams = CryptoJS.lib.CipherParams.create({
|
769 | * ciphertext: ciphertextWordArray,
|
770 | * key: keyWordArray,
|
771 | * iv: ivWordArray,
|
772 | * salt: saltWordArray,
|
773 | * algorithm: CryptoJS.algo.AES,
|
774 | * mode: CryptoJS.mode.CBC,
|
775 | * padding: CryptoJS.pad.PKCS7,
|
776 | * blockSize: 4,
|
777 | * formatter: CryptoJS.format.OpenSSL
|
778 | * });
|
779 | */
|
780 | create(cipherParams: Partial<CipherParams>): CipherParams;
|
781 | };
|
782 |
|
783 | /**
|
784 | * Abstract base stream cipher template.
|
785 | */
|
786 | interface StreamCipher extends Cipher {
|
787 | /**
|
788 | * The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
|
789 | */
|
790 | blockSize: number;
|
791 | }
|
792 |
|
793 | /**
|
794 | * Abstract base block cipher mode template.
|
795 | */
|
796 | const BlockCipherMode: any;
|
797 |
|
798 | /**
|
799 | * A cipher wrapper that returns ciphertext as a serializable cipher params object.
|
800 | */
|
801 | const SerializableCipher: {
|
802 | /**
|
803 | * Encrypts a message.
|
804 | *
|
805 | * @param cipher The cipher algorithm to use.
|
806 | * @param message The message to encrypt.
|
807 | * @param key The key.
|
808 | * @param cfg (Optional) The configuration options to use for this operation.
|
809 | *
|
810 | * @return A cipher params object.
|
811 | *
|
812 | * @example
|
813 | *
|
814 | * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
|
815 | * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
|
816 | * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
817 | */
|
818 | encrypt(
|
819 | cipher: CipherStatic,
|
820 | message: WordArray | string,
|
821 | key: WordArray,
|
822 | cfg?: CipherOption,
|
823 | ): CipherParams;
|
824 |
|
825 | /**
|
826 | * Decrypts serialized ciphertext.
|
827 | *
|
828 | * @param cipher The cipher algorithm to use.
|
829 | * @param ciphertext The ciphertext to decrypt.
|
830 | * @param key The key.
|
831 | * @param cfg (Optional) The configuration options to use for this operation.
|
832 | *
|
833 | * @return The plaintext.
|
834 | *
|
835 | * @example
|
836 | *
|
837 | * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
838 | * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
839 | */
|
840 | decrypt(
|
841 | cipher: CipherStatic,
|
842 | ciphertext: WordArray | string,
|
843 | key: WordArray,
|
844 | cfg?: CipherOption,
|
845 | ): CipherParams;
|
846 |
|
847 | /**
|
848 | * Converts serialized ciphertext to CipherParams,
|
849 | * else assumed CipherParams already and returns ciphertext unchanged.
|
850 | *
|
851 | * @param ciphertext The ciphertext.
|
852 | * @param format The formatting strategy to use to parse serialized ciphertext.
|
853 | *
|
854 | * @return The unserialized ciphertext.
|
855 | *
|
856 | * @example
|
857 | *
|
858 | * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
|
859 | */
|
860 | _parse(ciphertext: CipherParams | string, format: Format): CipherParams;
|
861 | };
|
862 |
|
863 | /**
|
864 | * A serializable cipher wrapper that derives the key from a password,
|
865 | * and returns ciphertext as a serializable cipher params object.
|
866 | */
|
867 | const PasswordBasedCipher: {
|
868 | /**
|
869 | * Encrypts a message using a password.
|
870 | *
|
871 | * @param cipher The cipher algorithm to use.
|
872 | * @param message The message to encrypt.
|
873 | * @param password The password.
|
874 | * @param cfg (Optional) The configuration options to use for this operation.
|
875 | *
|
876 | * @return A cipher params object.
|
877 | *
|
878 | * @example
|
879 | *
|
880 | * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
|
881 | * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
|
882 | */
|
883 | encrypt(
|
884 | cipher: CipherStatic,
|
885 | message: WordArray | string,
|
886 | password: string,
|
887 | cfg?: CipherOption,
|
888 | ): CipherParams;
|
889 |
|
890 | /**
|
891 | * Decrypts serialized ciphertext using a password.
|
892 | *
|
893 | * @param cipher The cipher algorithm to use.
|
894 | * @param ciphertext The ciphertext to decrypt.
|
895 | * @param password The password.
|
896 | * @param cfg (Optional) The configuration options to use for this operation.
|
897 | *
|
898 | * @return The plaintext.
|
899 | *
|
900 | * @example
|
901 | *
|
902 | * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
|
903 | * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
|
904 | */
|
905 | decrypt(
|
906 | cipher: CipherStatic,
|
907 | ciphertext: CipherParams | string,
|
908 | password: string,
|
909 | cfg?: CipherOption,
|
910 | ): WordArray;
|
911 | };
|
912 | }
|
913 | /**
|
914 | * Padding namespace.
|
915 | */
|
916 | export namespace pad {
|
917 | /**
|
918 | * PKCS #5/7 padding strategy.
|
919 | */
|
920 | const Pkcs7: Padding;
|
921 |
|
922 | /**
|
923 | * ANSI X.923 padding strategy.
|
924 | */
|
925 | const AnsiX923: Padding;
|
926 |
|
927 | /**
|
928 | * ISO 10126 padding strategy.
|
929 | */
|
930 | const Iso10126: Padding;
|
931 |
|
932 | /**
|
933 | * ISO/IEC 9797-1 Padding Method 2.
|
934 | */
|
935 | const Iso97971: Padding;
|
936 |
|
937 | /**
|
938 | * Zero padding strategy.
|
939 | */
|
940 | const ZeroPadding: Padding;
|
941 |
|
942 | /**
|
943 | * A noop padding strategy.
|
944 | */
|
945 | const NoPadding: Padding;
|
946 | }
|
947 |
|
948 | /**
|
949 | * Key derivation function namespace.
|
950 | */
|
951 | export namespace kdf {
|
952 | /**
|
953 | * OpenSSL key derivation function.
|
954 | */
|
955 | const OpenSSL: {
|
956 | /**
|
957 | * Derives a key and IV from a password.
|
958 | *
|
959 | * @param password The password to derive from.
|
960 | * @param keySize The size in words of the key to generate.
|
961 | * @param ivSize The size in words of the IV to generate.
|
962 | * @param salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
|
963 | *
|
964 | * @return A cipher params object with the key, IV, and salt.
|
965 | *
|
966 | * @example
|
967 | *
|
968 | * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
|
969 | * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
|
970 | */
|
971 | execute(password: string, keySize: number, ivSize: number, salt?: WordArray | string): CipherParams;
|
972 | };
|
973 | }
|
974 |
|
975 | /**
|
976 | * Mode namespace.
|
977 | */
|
978 | export namespace mode {
|
979 | /**
|
980 | * Cipher Block Chaining mode.
|
981 | */
|
982 | const CBC: BlockCipherMode;
|
983 |
|
984 | /**
|
985 | * Cipher Feedback block mode.
|
986 | */
|
987 | const CFB: BlockCipherMode;
|
988 | /**
|
989 | * Counter block mode.
|
990 | */
|
991 | const CTR: BlockCipherMode;
|
992 | /**
|
993 | * @preserve
|
994 | * Counter block mode compatible with Dr Brian Gladman fileenc.c
|
995 | * derived from CryptoJS.mode.CTR
|
996 | * Jan Hruby jhruby.web@gmail.com
|
997 | */
|
998 | const CTRGladman: BlockCipherMode;
|
999 | /**
|
1000 | * Output Feedback block mode.
|
1001 | */
|
1002 | const OFB: BlockCipherMode;
|
1003 |
|
1004 | /**
|
1005 | * Electronic Codebook block mode.
|
1006 | */
|
1007 | const ECB: BlockCipherMode;
|
1008 | }
|
1009 |
|
1010 | /**
|
1011 | * Format namespace.
|
1012 | */
|
1013 | export namespace format {
|
1014 | /**
|
1015 | * OpenSSL formatting strategy.
|
1016 | */
|
1017 | const OpenSSL: Format;
|
1018 | const Hex: Format;
|
1019 | }
|
1020 |
|
1021 | /**
|
1022 | * Encoder namespace.
|
1023 | */
|
1024 | export namespace enc {
|
1025 | /**
|
1026 | * Hex encoding strategy.
|
1027 | */
|
1028 | const Hex: Encoder;
|
1029 | /**
|
1030 | * Latin1 encoding strategy.
|
1031 | */
|
1032 | const Latin1: Encoder;
|
1033 | /**
|
1034 | * UTF-8 encoding strategy.
|
1035 | */
|
1036 | const Utf8: Encoder;
|
1037 | /**
|
1038 | * UTF-16 BE encoding strategy.
|
1039 | */
|
1040 | const Utf16: Encoder;
|
1041 | const Utf16BE: Encoder;
|
1042 |
|
1043 | /**
|
1044 | * UTF-16 LE encoding strategy.
|
1045 | */
|
1046 | const Utf16LE: Encoder;
|
1047 | /**
|
1048 | * Base64 encoding strategy.
|
1049 | */
|
1050 | const Base64: Encoder;
|
1051 | /**
|
1052 | * Base64url encoding strategy.
|
1053 | */
|
1054 | const Base64url: Encoder;
|
1055 | }
|
1056 |
|
1057 | /**
|
1058 | * Algorithm namespace.
|
1059 | */
|
1060 | export namespace algo {
|
1061 | /**
|
1062 | * MD5 hash algorithm.
|
1063 | */
|
1064 | const MD5: HasherStatic;
|
1065 |
|
1066 | /**
|
1067 | * SHA-1 hash algorithm.
|
1068 | */
|
1069 | const SHA1: HasherStatic;
|
1070 |
|
1071 | /**
|
1072 | * SHA-256 hash algorithm.
|
1073 | */
|
1074 | const SHA256: HasherStatic;
|
1075 | /**
|
1076 | * SHA-224 hash algorithm.
|
1077 | */
|
1078 | const SHA224: HasherStatic;
|
1079 | /**
|
1080 | * SHA-512 hash algorithm.
|
1081 | */
|
1082 | const SHA512: HasherStatic;
|
1083 |
|
1084 | /**
|
1085 | * SHA-384 hash algorithm.
|
1086 | */
|
1087 | const SHA384: HasherStatic;
|
1088 | /**
|
1089 | * SHA-3 hash algorithm.
|
1090 | */
|
1091 | const SHA3: HasherStatic;
|
1092 | /**
|
1093 | * RIPEMD160 hash algorithm.
|
1094 | */
|
1095 | const RIPEMD160: HasherStatic;
|
1096 | /**
|
1097 | * HMAC algorithm.
|
1098 | */
|
1099 | abstract class HMAC {
|
1100 | /**
|
1101 | * Initializes a newly created HMAC.
|
1102 | *
|
1103 | * @param hasher The hash algorithm to use.
|
1104 | * @param key The secret key.
|
1105 | *
|
1106 | * @example
|
1107 | *
|
1108 | * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
|
1109 | */
|
1110 | static create(hasher: HasherStatic, key: WordArray | string): HMAC;
|
1111 | /**
|
1112 | * Resets this HMAC to its initial state.
|
1113 | *
|
1114 | * @example
|
1115 | *
|
1116 | * hmacHasher.reset();
|
1117 | */
|
1118 | reset(): void;
|
1119 |
|
1120 | /**
|
1121 | * Updates this HMAC with a message.
|
1122 | *
|
1123 | * @param messageUpdate The message to append.
|
1124 | *
|
1125 | * @return This HMAC instance.
|
1126 | *
|
1127 | * @example
|
1128 | *
|
1129 | * hmacHasher.update('message');
|
1130 | * hmacHasher.update(wordArray);
|
1131 | */
|
1132 | update(messageUpdate: WordArray | string): this;
|
1133 |
|
1134 | /**
|
1135 | * Finalizes the HMAC computation.
|
1136 | * Note that the finalize operation is effectively a destructive, read-once operation.
|
1137 | *
|
1138 | * @param messageUpdate (Optional) A final message update.
|
1139 | *
|
1140 | * @return The HMAC.
|
1141 | *
|
1142 | * @example
|
1143 | *
|
1144 | * var hmac = hmacHasher.finalize();
|
1145 | * var hmac = hmacHasher.finalize('message');
|
1146 | * var hmac = hmacHasher.finalize(wordArray);
|
1147 | */
|
1148 | finalize(messageUpdate?: WordArray | string): WordArray;
|
1149 | }
|
1150 | /**
|
1151 | * Password-Based Key Derivation Function 2 algorithm.
|
1152 | */
|
1153 | abstract class PBKDF2 {
|
1154 | /**
|
1155 | * Initializes a newly created key derivation function.
|
1156 | *
|
1157 | * @param cfg (Optional) The configuration options to use for the derivation.
|
1158 | *
|
1159 | * @example
|
1160 | *
|
1161 | * var kdf = CryptoJS.algo.PBKDF2.create();
|
1162 | * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
|
1163 | * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
|
1164 | */
|
1165 | static create(cfg?: KDFOption): PBKDF2;
|
1166 |
|
1167 | /**
|
1168 | * Computes the Password-Based Key Derivation Function 2.
|
1169 | *
|
1170 | * @param password The password.
|
1171 | * @param salt A salt.
|
1172 | *
|
1173 | * @return The derived key.
|
1174 | *
|
1175 | * @example
|
1176 | *
|
1177 | * var key = kdf.compute(password, salt);
|
1178 | */
|
1179 | compute(password: WordArray | string, salt: WordArray): WordArray;
|
1180 | }
|
1181 | /**
|
1182 | * This key derivation function is meant to conform with EVP_BytesToKey.
|
1183 | * www.openssl.org/docs/crypto/EVP_BytesToKey.html
|
1184 | */
|
1185 | abstract class EvpKDF {
|
1186 | /**
|
1187 | * Initializes a newly created key derivation function.
|
1188 | *
|
1189 | * @param cfg (Optional) The configuration options to use for the derivation.
|
1190 | *
|
1191 | * @example
|
1192 | *
|
1193 | * var kdf = CryptoJS.algo.EvpKDF.create();
|
1194 | * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
|
1195 | * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
|
1196 | */
|
1197 | static create(cfg?: { keySize: number; hasher?: HasherStatic | undefined; iterations: number }): EvpKDF;
|
1198 |
|
1199 | /**
|
1200 | * Derives a key from a password.
|
1201 | *
|
1202 | * @param password The password.
|
1203 | * @param salt A salt.
|
1204 | *
|
1205 | * @return The derived key.
|
1206 | *
|
1207 | * @example
|
1208 | *
|
1209 | * var key = kdf.compute(password, salt);
|
1210 | */
|
1211 | compute(password: WordArray | string, salt: WordArray): WordArray;
|
1212 | }
|
1213 |
|
1214 | /**
|
1215 | * AES block cipher algorithm.
|
1216 | */
|
1217 | const AES: CipherStatic;
|
1218 |
|
1219 | /**
|
1220 | * DES block cipher algorithm.
|
1221 | */
|
1222 | const DES: CipherStatic;
|
1223 |
|
1224 | /**
|
1225 | * Triple-DES block cipher algorithm.
|
1226 | */
|
1227 | const TripleDES: CipherStatic;
|
1228 |
|
1229 | /**
|
1230 | * RC4 stream cipher algorithm.
|
1231 | */
|
1232 | const RC4: CipherStatic;
|
1233 |
|
1234 | /**
|
1235 | * Modified RC4 stream cipher algorithm.
|
1236 | */
|
1237 | const RC4Drop: CipherStatic;
|
1238 |
|
1239 | /**
|
1240 | * Rabbit stream cipher algorithm
|
1241 | */
|
1242 | const Rabbit: CipherStatic;
|
1243 |
|
1244 | /**
|
1245 | * Rabbit stream cipher algorithm.
|
1246 | *
|
1247 | * This is a legacy version that neglected to convert the key to little-endian.
|
1248 | * This error doesn't affect the cipher's security,
|
1249 | * but it does affect its compatibility with other implementations.
|
1250 | */
|
1251 | const RabbitLegacy: CipherStatic;
|
1252 | }
|
1253 |
|
1254 | /**
|
1255 | * x64 namespace.
|
1256 | */
|
1257 | export namespace x64 {
|
1258 | /**
|
1259 | * A 64-bit word.
|
1260 | */
|
1261 | interface Word {
|
1262 | /**
|
1263 | * Bitwise NOTs this word.
|
1264 | *
|
1265 | * @return A new x64-Word object after negating.
|
1266 | *
|
1267 | * @example
|
1268 | *
|
1269 | * var negated = x64Word.not();
|
1270 | */
|
1271 | not(): X64Word;
|
1272 | /**
|
1273 | * Bitwise ANDs this word with the passed word.
|
1274 | *
|
1275 | * @param word The x64-Word to AND with this word.
|
1276 | *
|
1277 | * @return A new x64-Word object after ANDing.
|
1278 | *
|
1279 | * @example
|
1280 | *
|
1281 | * var anded = x64Word.and(anotherX64Word);
|
1282 | */
|
1283 | and(word: X64Word): X64Word;
|
1284 |
|
1285 | /**
|
1286 | * Bitwise ORs this word with the passed word.
|
1287 | *
|
1288 | * @param word The x64-Word to OR with this word.
|
1289 | *
|
1290 | * @return A new x64-Word object after ORing.
|
1291 | *
|
1292 | * @example
|
1293 | *
|
1294 | * var ored = x64Word.or(anotherX64Word);
|
1295 | */
|
1296 | or(word: X64Word): X64Word;
|
1297 |
|
1298 | /**
|
1299 | * Bitwise XORs this word with the passed word.
|
1300 | *
|
1301 | * @param word The x64-Word to XOR with this word.
|
1302 | *
|
1303 | * @return A new x64-Word object after XORing.
|
1304 | *
|
1305 | * @example
|
1306 | *
|
1307 | * var xored = x64Word.xor(anotherX64Word);
|
1308 | */
|
1309 | xor(word: X64Word): X64Word;
|
1310 | /**
|
1311 | * Shifts this word n bits to the left.
|
1312 | *
|
1313 | * @param n The number of bits to shift.
|
1314 | *
|
1315 | * @return A new x64-Word object after shifting.
|
1316 | *
|
1317 | * @example
|
1318 | *
|
1319 | * var shifted = x64Word.shiftL(25);
|
1320 | */
|
1321 | shiftL(n: number): X64Word;
|
1322 | /**
|
1323 | * Shifts this word n bits to the right.
|
1324 | *
|
1325 | * @param n The number of bits to shift.
|
1326 | *
|
1327 | * @return A new x64-Word object after shifting.
|
1328 | *
|
1329 | * @example
|
1330 | *
|
1331 | * var shifted = x64Word.shiftR(7);
|
1332 | */
|
1333 | shiftR(n: number): X64Word;
|
1334 | /**
|
1335 | * Rotates this word n bits to the left.
|
1336 | *
|
1337 | * @param n The number of bits to rotate.
|
1338 | *
|
1339 | * @return A new x64-Word object after rotating.
|
1340 | *
|
1341 | * @example
|
1342 | *
|
1343 | * var rotated = x64Word.rotL(25);
|
1344 | */
|
1345 | rotL(n: number): X64Word;
|
1346 |
|
1347 | /**
|
1348 | * Rotates this word n bits to the right.
|
1349 | *
|
1350 | * @param n The number of bits to rotate.
|
1351 | *
|
1352 | * @return A new x64-Word object after rotating.
|
1353 | *
|
1354 | * @example
|
1355 | *
|
1356 | * var rotated = x64Word.rotR(7);
|
1357 | */
|
1358 | rotR(n: number): X64Word;
|
1359 | /**
|
1360 | * Adds this word with the passed word.
|
1361 | *
|
1362 | * @param word The x64-Word to add with this word.
|
1363 | *
|
1364 | * @return A new x64-Word object after adding.
|
1365 | *
|
1366 | * @example
|
1367 | *
|
1368 | * var added = x64Word.add(anotherX64Word);
|
1369 | */
|
1370 | add(word: X64Word): X64Word;
|
1371 | }
|
1372 |
|
1373 | const Word: {
|
1374 | /**
|
1375 | * Initializes a newly created 64-bit word.
|
1376 | *
|
1377 | * @param high The high 32 bits.
|
1378 | * @param low The low 32 bits.
|
1379 | *
|
1380 | * @example
|
1381 | *
|
1382 | * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
|
1383 | */
|
1384 | create(high: number, low: number): X64Word;
|
1385 | };
|
1386 |
|
1387 | /**
|
1388 | * Initializes a newly created word array.
|
1389 | *
|
1390 | * @param words (Optional) An array of CryptoJS.x64.Word objects.
|
1391 | * @param sigBytes (Optional) The number of significant bytes in the words.
|
1392 | *
|
1393 | * @example
|
1394 | *
|
1395 | * var wordArray = CryptoJS.x64.WordArray.create();
|
1396 | *
|
1397 | * var wordArray = CryptoJS.x64.WordArray.create([
|
1398 | * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
|
1399 | * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
|
1400 | * ]);
|
1401 | *
|
1402 | * var wordArray = CryptoJS.x64.WordArray.create([
|
1403 | * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
|
1404 | * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
|
1405 | * ], 10);
|
1406 | */
|
1407 | const WordArray: {
|
1408 | create(words?: X64WordArray[], sigBytes?: number): X64WordArray;
|
1409 | };
|
1410 | }
|
1411 |
|
1412 | /**
|
1413 | * Shortcut function to the hasher's object interface.
|
1414 | *
|
1415 | * @param message The message to hash.
|
1416 | *
|
1417 | * @return The hash.
|
1418 | *
|
1419 | * @example
|
1420 | *
|
1421 | * var hash = CryptoJS.MD5('message');
|
1422 | * var hash = CryptoJS.MD5(wordArray);
|
1423 | */
|
1424 | export const MD5: HasherHelper;
|
1425 | /**
|
1426 | * Shortcut function to the HMAC's object interface.
|
1427 | *
|
1428 | * @param message The message to hash.
|
1429 | * @param key The secret key.
|
1430 | *
|
1431 | * @return The HMA'C.
|
1432 | *
|
1433 | * @example
|
1434 | *
|
1435 | * var hmac = CryptoJS.HmacMD5(message, key);
|
1436 | */
|
1437 | export const HmacMD5: HmacHasherHelper;
|
1438 | /**
|
1439 | * Shortcut function to the hasher's object interface.
|
1440 | *
|
1441 | * @param message The message to hash.
|
1442 | *
|
1443 | * @return The hash.
|
1444 | *
|
1445 | * @example
|
1446 | *
|
1447 | * var hash = CryptoJS.SHA1('message');
|
1448 | * var hash = CryptoJS.SHA1(wordArray);
|
1449 | */
|
1450 | export const SHA1: HasherHelper;
|
1451 | /**
|
1452 | * Shortcut function to the HMAC's object interface.
|
1453 | *
|
1454 | * @param message The message to hash.
|
1455 | * @param key The secret key.
|
1456 | *
|
1457 | * @return The HMAC.
|
1458 | *
|
1459 | * @example
|
1460 | *
|
1461 | * var hmac = CryptoJS.HmacSHA1(message, key);
|
1462 | */
|
1463 | export const HmacSHA1: HmacHasherHelper;
|
1464 |
|
1465 | /**
|
1466 | * Shortcut function to the hasher's object interface.
|
1467 | *
|
1468 | * @param message The message to hash.
|
1469 | *
|
1470 | * @return The hash.
|
1471 | *
|
1472 | * @example
|
1473 | *
|
1474 | * var hash = CryptoJS.SHA256('message');
|
1475 | * var hash = CryptoJS.SHA256(wordArray);
|
1476 | */
|
1477 | export const SHA256: HasherHelper;
|
1478 | /**
|
1479 | * Shortcut function to the HMAC's object interface.
|
1480 | *
|
1481 | * @param message The message to hash.
|
1482 | * @param key The secret key.
|
1483 | *
|
1484 | * @return The HMAC.
|
1485 | *
|
1486 | * @example
|
1487 | *
|
1488 | * var hmac = CryptoJS.HmacSHA256(message, key);
|
1489 | */
|
1490 | export const HmacSHA256: HmacHasherHelper;
|
1491 | /**
|
1492 | * Shortcut function to the hasher's object interface.
|
1493 | *
|
1494 | * @param message The message to hash.
|
1495 | *
|
1496 | * @return The hash.
|
1497 | *
|
1498 | * @example
|
1499 | *
|
1500 | * var hash = CryptoJS.SHA224('message');
|
1501 | * var hash = CryptoJS.SHA224(wordArray);
|
1502 | */
|
1503 | export const SHA224: HasherHelper;
|
1504 | /**
|
1505 | * Shortcut function to the HMAC's object interface.
|
1506 | *
|
1507 | * @param message The message to hash.
|
1508 | * @param key The secret key.
|
1509 | *
|
1510 | * @return The HMAC.
|
1511 | *
|
1512 | * @example
|
1513 | *
|
1514 | * var hmac = CryptoJS.HmacSHA224(message, key);
|
1515 | */
|
1516 | export const HmacSHA224: HmacHasherHelper;
|
1517 | /**
|
1518 | * Shortcut function to the hasher's object interface.
|
1519 | *
|
1520 | * @param message The message to hash.
|
1521 | *
|
1522 | * @return The hash.
|
1523 | *
|
1524 | * @example
|
1525 | *
|
1526 | * var hash = CryptoJS.SHA512('message');
|
1527 | * var hash = CryptoJS.SHA512(wordArray);
|
1528 | */
|
1529 | export const SHA512: HasherHelper;
|
1530 | /**
|
1531 | * Shortcut function to the HMAC's object interface.
|
1532 | *
|
1533 | * @param message The message to hash.
|
1534 | * @param key The secret key.
|
1535 | *
|
1536 | * @return The HMAC.
|
1537 | *
|
1538 | * @example
|
1539 | *
|
1540 | * var hmac = CryptoJS.HmacSHA512(message, key);
|
1541 | */
|
1542 | export const HmacSHA512: HmacHasherHelper;
|
1543 | /**
|
1544 | * Shortcut function to the hasher's object interface.
|
1545 | *
|
1546 | * @param message The message to hash.
|
1547 | *
|
1548 | * @return The hash.
|
1549 | *
|
1550 | * @example
|
1551 | *
|
1552 | * var hash = CryptoJS.SHA384('message');
|
1553 | * var hash = CryptoJS.SHA384(wordArray);
|
1554 | */
|
1555 | export const SHA384: HasherHelper;
|
1556 | /**
|
1557 | * Shortcut function to the HMAC's object interface.
|
1558 | *
|
1559 | * @param message The message to hash.
|
1560 | * @param key The secret key.
|
1561 | *
|
1562 | * @return The HMAC.
|
1563 | *
|
1564 | * @example
|
1565 | *
|
1566 | * var hmac = CryptoJS.HmacSHA384(message, key);
|
1567 | */
|
1568 | export const HmacSHA384: HmacHasherHelper;
|
1569 |
|
1570 | /**
|
1571 | * Shortcut function to the hasher's object interface.
|
1572 | *
|
1573 | * @param message The message to hash.
|
1574 | *
|
1575 | * @return The hash.
|
1576 | *
|
1577 | * @example
|
1578 | *
|
1579 | * var hash = CryptoJS.SHA3('message');
|
1580 | * var hash = CryptoJS.SHA3(wordArray);
|
1581 | */
|
1582 | export const SHA3: HasherHelper;
|
1583 | /**
|
1584 | * Shortcut function to the HMAC's object interface.
|
1585 | *
|
1586 | * @param message The message to hash.
|
1587 | * @param key The secret key.
|
1588 | *
|
1589 | * @return The HMAC.
|
1590 | *
|
1591 | * @example
|
1592 | *
|
1593 | * var hmac = CryptoJS.HmacSHA3(message, key);
|
1594 | */
|
1595 | export const HmacSHA3: HmacHasherHelper;
|
1596 |
|
1597 | /**
|
1598 | * Shortcut function to the hasher's object interface.
|
1599 | *
|
1600 | * @param message The message to hash.
|
1601 | *
|
1602 | * @return The hash.
|
1603 | *
|
1604 | * @example
|
1605 | *
|
1606 | * var hash = CryptoJS.RIPEMD160('message');
|
1607 | * var hash = CryptoJS.RIPEMD160(wordArray);
|
1608 | */
|
1609 | export const RIPEMD160: HasherHelper;
|
1610 | /**
|
1611 | * Shortcut function to the HMAC's object interface.
|
1612 | *
|
1613 | * @param message The message to hash.
|
1614 | * @param key The secret key.
|
1615 | *
|
1616 | * @return The HMAC.
|
1617 | *
|
1618 | * @example
|
1619 | *
|
1620 | * var hmac = CryptoJS.HmacRIPEMD160(message, key);
|
1621 | */
|
1622 | export const HmacRIPEMD160: HmacHasherHelper;
|
1623 | /**
|
1624 | * Computes the Password-Based Key Derivation Function 2.
|
1625 | *
|
1626 | * @param password The password.
|
1627 | * @param salt A salt.
|
1628 | * @param cfg (Optional) The configuration options to use for this computation.
|
1629 | *
|
1630 | * @return The derived key.
|
1631 | *
|
1632 | * @example
|
1633 | *
|
1634 | * var key = CryptoJS.PBKDF2(password, salt);
|
1635 | * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
|
1636 | * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
|
1637 | */
|
1638 | export function PBKDF2(password: WordArray | string, salt: WordArray | string, cfg?: KDFOption): WordArray;
|
1639 |
|
1640 | /**
|
1641 | * Shortcut functions to the cipher's object interface.
|
1642 | *
|
1643 | * @example
|
1644 | *
|
1645 | * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
|
1646 | * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
|
1647 | */
|
1648 | export const AES: CipherHelper;
|
1649 |
|
1650 | /**
|
1651 | * Shortcut functions to the cipher's object interface.
|
1652 | *
|
1653 | * @example
|
1654 | *
|
1655 | * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
|
1656 | * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
|
1657 | */
|
1658 | export const DES: CipherHelper;
|
1659 |
|
1660 | /**
|
1661 | * Shortcut functions to the cipher's object interface.
|
1662 | *
|
1663 | * @example
|
1664 | *
|
1665 | * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
|
1666 | * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
|
1667 | */
|
1668 | export const TripleDES: CipherHelper;
|
1669 |
|
1670 | /**
|
1671 | * Shortcut functions to the cipher's object interface.
|
1672 | *
|
1673 | * @example
|
1674 | *
|
1675 | * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
|
1676 | * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
|
1677 | */
|
1678 | export const RC4: CipherHelper;
|
1679 |
|
1680 | /**
|
1681 | * Shortcut functions to the cipher's object interface.
|
1682 | *
|
1683 | * @example
|
1684 | *
|
1685 | * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
|
1686 | * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
|
1687 | */
|
1688 | export const RC4Drop: CipherHelper;
|
1689 |
|
1690 | /**
|
1691 | * Shortcut functions to the cipher's object interface.
|
1692 | *
|
1693 | * @example
|
1694 | *
|
1695 | * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
|
1696 | * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
|
1697 | */
|
1698 | export const Rabbit: CipherHelper;
|
1699 |
|
1700 | /**
|
1701 | * Shortcut functions to the cipher's object interface.
|
1702 | *
|
1703 | * @example
|
1704 | *
|
1705 | * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
|
1706 | * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
|
1707 | */
|
1708 | export const RabbitLegacy: CipherHelper;
|
1709 |
|
1710 | /**
|
1711 | * Derives a key from a password.
|
1712 | *
|
1713 | * @param password The password.
|
1714 | * @param salt A salt.
|
1715 | * @param cfg (Optional) The configuration options to use for this computation.
|
1716 | *
|
1717 | * @return The derived key.
|
1718 | *
|
1719 | * @example
|
1720 | *
|
1721 | * var key = CryptoJS.EvpKDF(password, salt);
|
1722 | * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
|
1723 | * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
|
1724 | */
|
1725 | export function EvpKDF(
|
1726 | password: WordArray | string,
|
1727 | salt: WordArray | string,
|
1728 | cfg?: {
|
1729 | keySize: number;
|
1730 | hasher?: HasherStatic | undefined;
|
1731 | iterations: number;
|
1732 | },
|
1733 | ): WordArray;
|
1734 | }
|
1735 | }
|