-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.d.ts
2031 lines (1896 loc) · 62.5 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// the following TypeScripts is ported from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/crypto-js/index.d.ts
// added TypeScript definitions for crypto-js-wasm
interface WasmHasherHelper extends HasherHelper {
/**
* Async call to load thw wasm binary
*/
loadWasm(): Promise<void>;
}
interface WasmHasherStatic extends HasherStatic {
/**
* Async call to load thw wasm binary
*/
loadWasm(): Promise<void>;
}
interface WasmHmacHasherHelper extends HmacHasherHelper {
/**
* Async call to load thw wasm binary
*/
loadWasm(): Promise<void>;
}
interface WasmCipherHelper extends CipherHelper {
/**
* Async call to load thw wasm binary
*/
loadWasm(): Promise<void>;
}
interface WasmCipherStatic extends CipherStatic {
/**
* Async call to load thw wasm binary
*/
loadWasm(): Promise<void>;
}
/**
* encryptPadding: encrypt padding mode, values may be 'OAEP'(default)/'PKCS1V15'
* signPadding: sign padding mode, values may be 'PSS'(default)/'PKCS1V15'
* hashAlgo: hasher for encryption and sign, values may be 'sha256'(default)/'md5'/'sha1'/'sha224'/'sha384'/'sha512'/'ripemd160'
* key: can be path to the RSA key file(string), the content of RSA key(string), or the size of the RSA key(number)
* isPublicKey: true if the cfg.key is the RSA public key
*/
interface RSAConfig {
/**
* encrypt padding mode, values may be 'OAEP'(default)/'PKCS1V15'
*/
encryptPadding?: string,
/**
* sign padding mode, values may be 'PSS'(default)/'PKCS1V15'
*/
signPadding?: string,
/**
* hasher for encryption and sign, values may be 'sha256'(default)/'md5'/'sha1'/'sha224'/'sha384'/'sha512'/'ripemd160'
*/
hashAlgo?: string,
/**
* can be path to the RSA key file(string), the content of RSA key(string), or the size of the RSA key(number)
*/
key?: string|number,
/**
* true if the cfg.key is the RSA public key
*/
isPublicKey?: boolean
}
interface RSAAlgoShortcut {
/**
* Async call to load thw wasm binary
*/
loadWasm(): Promise<void>;
/**
* Reset configs to default values
*/
resetConfig(): void;
/**
* Update the key of RSA. The input can be a path to the private/public key file, or the key size in bits
*
* @param keyFilePathOrKeySize {string | number} the key file path or key size in bytes, set as 2048 bits as default
* @param isPublicKey true if the input key file is a public key file
*/
updateRsaKey(keyFilePathOrKeySize?: string|number, isPublicKey?: boolean): void;
/**
* Update the config for rsa. The configs of RSA are:
* encryptPadding: encrypt padding mode, values may be 'OAEP'(default)/'PKCS1V15'
* signPadding: sign padding mode, values may be 'PSS'(default)/'PKCS1V15'
* hashAlgo: hasher for encryption and sign, values may be 'sha256'(default)/'md5'/'sha1'/'sha224'/'sha384'/'sha512'/'ripemd160'
* key: can be path to the RSA key file(string), the content of RSA key(string), or the size of the RSA key(number)
* isPublicKey: true if the cfg.key is the RSA public key
*
* @param cfg {object} the config for rsa
*/
updateConfig(cfg?: RSAConfig): void;
/**
* Encrypt the given message
*
* @param {string | Uint8Array} msg the original message
* @param {object} cfg RSA configurations
* @returns {Uint8Array} the encrypted message
*/
encrypt(msg: string|Uint8Array, cfg?: RSAConfig): Uint8Array;
/**
* Decrypt the given message
*
* @param {Uint8Array} msgEncrypted the encrypted message
* @param {object} cfg RSA configurations
* @returns {Uint8Array} the decrypted message
*/
decrypt(msgEncrypted: Uint8Array, cfg?: RSAConfig): Uint8Array;
/**
* Generate the digest of the input message according to the specified hash algorithm
*
* @param {string} msg input message
* @param {object} cfg RSA configurations
* @returns {Uint8Array} the digest of input message
*/
digest(msg: string, cfg?: RSAConfig): Uint8Array;
/**
* RSA sign
*
* @param {string | Uint8Array} digest the digest of the message
* @param {object} cfg RSA configurations
* @returns {Uint8Array} the rsa signature
*/
sign(digest: string|Uint8Array, cfg?: RSAConfig): Uint8Array;
/**
* Verify the given RSA signature
*
* @param {Uint8Array} digest the digest of the message
* @param {Uint8Array} signature the signature signed using private key
* @param {object} cfg RSA configurations
* @returns {boolean} true if signature is valid
*/
verify(digest: Uint8Array, signature: Uint8Array, cfg?: RSAConfig): boolean;
/**
* generate the key file in specific directory
*
* @param {string} keyType valid values are 'pairs', 'private', 'public'. Default to be 'pairs'
* @param {string} fileFmt file type of the generated key file. Valid values are 'pem', 'der'. Default to be 'pem'
* @param {string} fileName the name of the generated key file
* @param {string} dir the dir of the generated key file
*/
generateKeyFile(keyType?: string, fileFmt?: string, fileName?: string, dir?: string): void;
/**
* Get current key type
* @returns {string} key type, may be 'public' or 'private'
*/
getKeyType(): string;
/**
* Get current key size
*
* @returns {number} key size in bytes, e.g. 128 for key pair of 1024 bits
*/
getKeySize(): number;
/**
* Get key content based on key type
*
* @param keyType the type of key files. Should be "private" or "public"
* @param keyFmt the encoding scheme. Should be "pem" or "der"
* @returns {string} the key content
*/
getKeyContent(keyType: string, keyFmt?: string): string;
}
interface WasmRSAAlgoClass extends RSAAlgoShortcut{
/**
* Constructor of RSAAlgo
*
* @param keyFilePathOrKeySize {string | number} the key file path or key size in bytes, set as 2048 bits as default
* @param cfg {object} the config for rsa
*/
constructor(keyFilePathOrKeySize?: string|number, cfg?: object): WasmRSAAlgoClass;
/**
* init keys from key file or key size
*/
initKeys(): void;
/**
* Return true if the given string is a rsa key content
*
* @param content the input content
* @returns {boolean} true if the given string is a rsa key content
*/
isRsaKeyContent(content: string): boolean;
/**
* Init rsa keys with given key content
*
* @param keyContent the input key content
* @param isPublicKey true if the input content is a public content
*/
initFromKeyContent(keyContent:string, isPublicKey?: boolean): void;
/**
* Init rsa keys with given key file
* @param path the input key file path
* @param isPublicKey true if the input key file is a public key file
*/
initFromKeyFile(path: string, isPublicKey?: boolean): void;
/**
* Init rsa keys with given key size
* @param bits key size in bytes
*/
initFromKeySize(bits: number): void;
/**
* Update encrypt padding of RSA.
* Valid values are 'OAEP'/'PKCS1V15'
*
* @param encryptPadding new padding mode of RSA encrypt
*/
updateEncryptPadding(encryptPadding: string): void;
/**
* Update sign padding of RSA.
* Valid values are 'PSS'/'PKCS1V15'
*
* @param signPadding new padding mode of RSA sign
*/
updateSignPadding(signPadding: string): void;
/**
* Update hash algorithm of RSA.
* Valid values are 'MD5', 'SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512', 'RIPEMD160'
*
* @param hashAlgo new hash algorithm of RSA
*/
updateHashAlgo(hashAlgo: string): void;
}
// original type definitions for crypto-js, some definitions are modified
// Type definitions for crypto-js 4.1
// Project: https://github.com/brix/crypto-js
// Definitions by: Michael Zabka <https://github.com/misak113>
// Max Lysenko <https://github.com/maximlysenko>
// Brendan Early <https://github.com/mymindstorm>
// Doma <https://github.com/SevenOutman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = CryptoJSWasm;
type WordArray = CryptoJSWasm.lib.WordArray;
type CipherParams = CryptoJSWasm.lib.CipherParams;
type X64Word = CryptoJSWasm.x64.Word;
/**
* Encoding strategy.
*/
interface Encoder {
/**
* Converts a word array to a hex string.
*
* @param wordArray The word array.
*
* @return The hex string.
*
* @example
*
* var hexString = CryptoJSWasm.enc.Hex.stringify(wordArray);
*/
stringify(wordArray: WordArray): string;
/**
* Converts a hex string to a word array.
*
* @param hexStr The hex string.
*
* @return The word array.
*
* @example
*
* var wordArray = CryptoJSWasm.enc.Hex.parse(hexString);
*/
parse(str: string): WordArray;
}
/**
* Abstract buffered block algorithm template.
*
* The property blockSize must be implemented in a concrete subtype.
*/
interface BufferedBlockAlgorithm {
/**
* The number of blocks that should be kept unprocessed in the buffer. Default: 0
*/
_minBufferSize: number;
/**
* Resets this block algorithm's data buffer to its initial state.
*
* @example
*
* bufferedBlockAlgorithm.reset();
*/
reset(): void;
/**
* Adds new data to this block algorithm's buffer.
*
* @param data The data to append. Strings are converted to a WordArray using UTF-8.
*
* @example
*
* bufferedBlockAlgorithm._append('data');
* bufferedBlockAlgorithm._append(wordArray);
*/
_append(data: WordArray | string): void;
/**
* Processes available data blocks.
*
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
*
* @param doFlush Whether all blocks and partial blocks should be processed.
*
* @return The processed data.
*
* @example
*
* var processedData = bufferedBlockAlgorithm._process();
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
*/
_process(doFlush?: boolean): WordArray;
/**
* Creates a copy of this object.
*
* @return The clone.
*
* @example
*
* var clone = bufferedBlockAlgorithm.clone();
*/
clone(): BufferedBlockAlgorithm;
}
/**
* Abstract hasher template.
*/
interface Hasher {
/**
* The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
*/
blockSize: number;
/**
* Resets this hasher to its initial state.
*
* @example
*
* hasher.reset();
*/
reset(): void;
/**
* Updates this hasher with a message.
*
* @param messageUpdate The message to append.
*
* @return This hasher.
*
* @example
*
* hasher.update('message');
* hasher.update(wordArray);
*/
update(messageUpdate: WordArray | string): this;
/**
* Finalizes the hash computation.
* Note that the finalize operation is effectively a destructive, read-once operation.
*
* @param messageUpdate (Optional) A final message update.
*
* @return The hash.
*
* @example
*
* var hash = hasher.finalize();
* var hash = hasher.finalize('message');
* var hash = hasher.finalize(wordArray);
*/
finalize(messageUpdate?: WordArray | string): WordArray;
}
interface HasherStatic {
/**
* Initializes a newly created hasher.
*
* @param cfg (Optional) The configuration options to use for this hash computation.
*
* @example
*
* var hasher = CryptoJSWasm.algo.SHA256.create();
*/
create(cfg?: object): Hasher;
}
interface HasherHelper {
(message: WordArray | string, cfg?: object): WordArray;
}
interface HmacHasherHelper {
(message: WordArray | string, key: WordArray | string): WordArray;
}
/**
* Abstract base cipher template.
*/
interface Cipher {
/**
* This cipher's key size. Default: 4 (128 bits)
*/
keySize: number;
/**
* This cipher's IV size. Default: 4 (128 bits)
*/
ivSize: number;
/**
* A constant representing encryption mode.
*/
readonly _ENC_XFORM_MODE: number;
/**
* A constant representing decryption mode.
*/
readonly _DEV_XFORM_MODE: number;
/**
* Resets this cipher to its initial state.
*
* @example
*
* cipher.reset();
*/
reset(): void;
/**
* Adds data to be encrypted or decrypted.
*
* @param dataUpdate The data to encrypt or decrypt.
*
* @return The data after processing.
*
* @example
*
* var encrypted = cipher.process('data');
* var encrypted = cipher.process(wordArray);
*/
process(dataUpdate: WordArray | string): WordArray;
/**
* Finalizes the encryption or decryption process.
* Note that the finalize operation is effectively a destructive, read-once operation.
*
* @param dataUpdate The final data to encrypt or decrypt.
*
* @return The data after final processing.
*
* @example
*
* var encrypted = cipher.finalize();
* var encrypted = cipher.finalize('data');
* var encrypted = cipher.finalize(wordArray);
*/
finalize(dataUpdate?: WordArray | string): WordArray;
}
interface CipherStatic {
/**
* Creates this cipher in encryption mode.
*
* @param key The key.
* @param cfg (Optional) The configuration options to use for this operation.
*
* @return A cipher instance.
*
* @example
*
* var cipher = CryptoJSWasm.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
*/
createEncryptor(key: WordArray, cfg?: CipherOption): Cipher;
/**
* Creates this cipher in decryption mode.
*
* @param key The key.
* @param cfg (Optional) The configuration options to use for this operation.
*
* @return A cipher instance.
*
* @example
*
* var cipher = CryptoJSWasm.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
*/
createDecryptor(key: WordArray, cfg?: CipherOption): Cipher;
/**
* Initializes a newly created cipher.
*
* @param xformMode Either the encryption or decryption transormation mode constant.
* @param key The key.
* @param cfg (Optional) The configuration options to use for this operation.
*
* @example
*
* var cipher = CryptoJSWasm.algo.AES.create(CryptoJSWasm.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
*/
create(xformMode: number, key: WordArray, cfg?: CipherOption): Cipher;
}
interface CipherHelper {
encrypt(message: WordArray | string, key: WordArray | string, cfg?: CipherOption): CipherParams;
decrypt(ciphertext: CipherParams | string, key: WordArray | string, cfg?: CipherOption): WordArray;
}
/**
* Configuration options.
*/
interface CipherOption {
/**
* The IV to use for this operation.
*/
iv?: WordArray | undefined;
format?: Format | undefined;
[key: string]: any;
}
interface Mode {
/**
* Processes the data block at offset.
*
* @param words The data words to operate on.
* @param offset The offset where the block starts.
*
* @example
*
* mode.processBlock(data.words, offset);
*/
processBlock(words: number[], offset: number): void;
}
interface ModeStatic {
/**
* Initializes a newly created mode.
*
* @param cipher A block cipher instance.
* @param iv The IV words.
*
* @example
*
* var mode = CryptoJSWasm.mode.CBC.Encryptor.create(cipher, iv.words);
*/
create(cipher: Cipher, iv: number[]): Mode;
}
/**
* Abstract base block cipher mode template.
*/
interface BlockCipherMode {
Encryptor: ModeStatic;
Decryptor: ModeStatic;
/**
* Creates this mode for encryption.
*
* @param cipher A block cipher instance.
* @param iv The IV words.
*
* @example
*
* var mode = CryptoJSWasm.mode.CBC.createEncryptor(cipher, iv.words);
*/
createEncryptor(cipher: Cipher, iv: number[]): Mode;
/**
* Creates this mode for decryption.
*
* @param cipher A block cipher instance.
* @param iv The IV words.
*
* @example
*
* var mode = CryptoJSWasm.mode.CBC.createDecryptor(cipher, iv.words);
*/
createDecryptor(cipher: Cipher, iv: number[]): Mode;
}
/**
* Abstract base block cipher mode template.
*/
interface BlockCipherMode {
/**
* Creates this mode for encryption.
*
* @param cipher A block cipher instance.
* @param iv The IV words.
*
* @example
*
* var mode = CryptoJSWasm.mode.CBC.createEncryptor(cipher, iv.words);
*/
createEncryptor(cipher: Cipher): Mode;
}
/**
* Padding strategy.
*/
interface Padding {
/**
* Pads data using the algorithm defined in PKCS #5/7.
*
* @param data The data to pad.
* @param blockSize The multiple that the data should be padded to.
*
* @example
*
* CryptoJSWasm.pad.Pkcs7.pad(wordArray, 4);
*/
pad(data: WordArray, blockSize: number): void;
/**
* Unpads data that had been padded using the algorithm defined in PKCS #5/7.
*
* @param data The data to unpad.
*
* @example
*
* CryptoJSWasm.pad.Pkcs7.unpad(wordArray);
*/
unpad(data: WordArray): void;
}
/**
* Abstract base block cipher template.
*/
interface BlockCipher {
/**
* The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
*/
blockSize: number;
}
/**
* Configuration options.
*/
interface BlockCipherOption {
/**
* The block mode to use. Default: CBC
*/
mode: Mode;
/**
* The padding strategy to use. Default: Pkcs7
*/
padding: Padding;
}
/**
* Formatting strategy.
*/
interface Format {
/**
* Converts a cipher params object to an OpenSSL-compatible string.
*
* @param cipherParams The cipher params object.
*
* @return The OpenSSL-compatible string.
*
* @example
*
* var openSSLString = CryptoJSWasm.format.OpenSSL.stringify(cipherParams);
*/
stringify(cipherParams: CipherParams): string;
/**
* Converts an OpenSSL-compatible string to a cipher params object.
*
* @param openSSLStr The OpenSSL-compatible string.
*
* @return The cipher params object.
*
* @example
*
* var cipherParams = CryptoJSWasm.format.OpenSSL.parse(openSSLString);
*/
parse(str: string): CipherParams;
}
/**
* An array of 64-bit words.
*/
interface X64WordArray {
/**
* The array of CryptoJSWasm.x64.Word objects.
*/
words: number[];
/**
* The number of significant bytes in this word array.
*/
sigBytes: number;
/**
* Converts this 64-bit word array to a 32-bit word array.
*
* @return This word array's data as a 32-bit word array.
*
* @example
*
* var x32WordArray = x64WordArray.toX32();
*/
toX32(): WordArray;
/**
* Creates a copy of this word array.
*
* @return The clone.
*
* @example
*
* var clone = x64WordArray.clone();
*/
clone(): X64WordArray;
}
/**
* Base object for prototypal inheritance.
*/
interface Base {
/**
* Creates a copy of this object.
*
* @return The clone.
*
* @example
*
* var clone = instance.clone();
*/
clone(): this;
}
/**
* Configuration options.
*/
interface KDFOption {
/**
* The key size in words to generate.
*/
keySize?: number | undefined;
/**
* The hasher to use.
*/
hasher?: WasmHasherStatic | undefined;
/**
* The number of iterations to perform.
*/
iterations?: number | undefined;
}
declare global {
namespace CryptoJSWasm {
/**
* Library namespace.
*/
export namespace lib {
/**
* Base object for prototypal inheritance.
*/
const Base: {
/**
* Creates a new object that inherits from this object.
*
* @param overrides Properties to copy into the new object.
*
* @return The new object.
*
* @example
*
* var MyType = CryptoJSWasm.lib.Base.extend({
* field: 'value',
*
* method: function () {
* }
* });
*/
extend(overrides: object): any;
/**
* Extends this object and runs the init method.
* Arguments to create() will be passed to init().
*
* @return The new object.
*
* @example
*
* var instance = MyType.create();
*/
create(...args: any[]): any;
/**
* Copies properties into this object.
*
* @param properties The properties to mix in.
*
* @example
*
* MyType.mixIn({
* field: 'value'
* });
*/
mixIn(properties: object): any;
};
/**
* An array of 32-bit words.
*/
interface WordArray {
/**
* The array of 32-bit words.
*/
words: number[];
/**
* The number of significant bytes in this word array.
*/
sigBytes: number;
/**
* Converts this word array to a string.
*
* @param encoder (Optional) The encoding strategy to use. Default: CryptoJSWasm.enc.Hex
*
* @return The stringified word array.
*
* @example
*
* var string = wordArray + '';
* var string = wordArray.toString();
* var string = wordArray.toString(CryptoJSWasm.enc.Utf8);
*/
toString(encoder?: Encoder): string;
/**
* Concatenates a word array to this word array.
*
* @param wordArray The word array to append.
*
* @return This word array.
*
* @example
*
* wordArray1.concat(wordArray2);
*/
concat(wordArray: WordArray): this;
/**
* Removes insignificant bits.
*
* @example
*
* wordArray.clamp();
*/
clamp(): void;
/**
* Creates a copy of this word array.
*
* @return The clone.
*
* @example
*
* var clone = wordArray.clone();
*/
clone(): WordArray;
}
const WordArray: {
/**
* Initializes a newly created word array.
*
* @param words (Optional) An array of 32-bit words.
* @param sigBytes (Optional) The number of significant bytes in the words.
*
* @example
*
* var wordArray = CryptoJSWasm.lib.WordArray.create();
* var wordArray = CryptoJSWasm.lib.WordArray.create([0x00010203, 0x04050607]);
* var wordArray = CryptoJSWasm.lib.WordArray.create([0x00010203, 0x04050607], 6);
*/
create(words?: number[] | Uint8Array | Int8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array, sigBytes?: number): WordArray;
/**
* Creates a word array filled with random bytes.
*
* @param nBytes The number of random bytes to generate.
*
* @return The random word array.
*
* @example
*
* var wordArray = CryptoJSWasm.lib.WordArray.random(16);
*/
random(nBytes: number): WordArray;
};
const BufferedBlockAlgorithm: any;
const Hasher: {
/**
* Creates a shortcut function to a hasher's object interface.
*
* @param hasher The hasher to create a helper for.
*
* @return The shortcut function.
*
* @example
*
* var SHA256 = CryptoJSWasm.lib.Hasher._createHelper(CryptoJSWasm.algo.SHA256);
*/
_createHelper(hasher: WasmHasherStatic): WasmHasherHelper;
/**
* Creates a shortcut function to the HMAC's object interface.
*
* @param hasher The hasher to use in this HMAC helper.
*
* @return The shortcut function.
*
* @example
*
* var HmacSHA256 = CryptoJSWasm.lib.Hasher._createHmacHelper(CryptoJSWasm.algo.SHA256);
*/
_createHmacHelper(hasher: WasmHasherStatic): WasmHmacHasherHelper;
};
const Cipher: {
/**
* Creates shortcut functions to a cipher's object interface.
*
* @param cipher The cipher to create a helper for.
*
* @return An object with encrypt and decrypt shortcut functions.
*
* @example
*
* var AES = CryptoJSWasm.lib.Cipher._createHelper(CryptoJSWasm.algo.AES);
*/
_createHelper(cipher: Cipher): WasmCipherHelper;
};
/**
* A collection of cipher parameters.
*/
interface CipherParams {
/**
* The raw ciphertext.
*/
ciphertext: WordArray;
/**
* The key to this ciphertext.
*/
key: WordArray;
/**
* The IV used in the ciphering operation.
*/
iv: WordArray;
/**
* The salt used with a key derivation function.
*/
salt: WordArray;
/**
* The cipher algorithm.
*/
algorithm: WasmCipherStatic;
/**
* The block mode used in the ciphering operation.
*/
mode: Mode;
/**
* The padding scheme used in the ciphering operation.
*/
padding: Padding;
/**
* The block size of the cipher.
*/
blockSize: number;
/**
* The default formatting strategy to convert this cipher params object to a string.
*/
formatter: Format;
/**
* Converts this cipher params object to a string.
*
* @param formatter (Optional) The formatting strategy to use.
*