/
index.d.ts
285 lines (254 loc) · 8.55 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
declare namespace cryptwist {
export declare namespace encoder {
abstract class Encoder {
/**
* the name of current encoder
*/
static title: string;
/**
* encode message using current encoder
*
* @argument msg message to be encoded
* @returns encoding result
*/
static encode: (msg: Uint8Array) => Uint8Array;
/**
* decode message using current encoder (decoder)
*
* @argument msg encoded message to be decoded
* @returns decoding result
*/
static decode: (code: Uint8Array) => Uint8Array;
}
export class Base64Encoder extends Encoder { }
export class Base32Encoder extends Encoder { }
export class Base16Encoder extends Encoder { }
export class Base85Encoder extends Encoder { }
export class HexEncoder extends Encoder { }
export class AsciiArmoredEncoder extends Encoder { }
export class AsciiEncoder extends Encoder { }
const encoderList: Array<typeof Encoder>;
const getEncoder: (string) => (typeof Encoder)?;
}
export declare namespace compressor {
abstract class Compressor {
/**
* the name of current compressor
*/
static title: string;
/**
* compress message using current compressor
*
* @argument msg message to be compressed
* @returns compression result
*/
static compress: (msg: Uint8Array) => Uint8Array;
/**
* decompress message using current compressor (decompressor)
*
* @argument msg compressed message to be decompressed
* @returns decompression result
*/
static decompress: (code: Uint8Array) => Uint8Array;
}
export class DeflateCompressor extends Compressor { };
export class ZlibCompressor extends Compressor { };
export class GzipCompressor extends Compressor { };
const compressorList: Array<typeof Compressor>;
const getCompressor: (string) => (typeof Compressor)?;
}
export declare namespace blockCipher {
abstract class BlockCipher {
/**
* the name of current block cipher
*/
static title: string;
/**
* construct lock cipher using key
* @param key key used in the cipher
*/
constructor(key: Uint8Array);
/**
* encrypt message using current cipher
*
* @argument msg message to be encrypted
* @returns encryption result
*/
encrypt: (msg: Uint8Array) => Uint8Array;
/**
* decrypt message using current cipher
*
* @argument cipher cipher text
* @returns decrypted plain message
*/
decrypt: (cipher: Uint8Array) => Uint8Array;
}
export class AES128BlockCipher extends BlockCipher { }
export class AES192BlockCipher extends BlockCipher { }
export class AES256BlockCipher extends BlockCipher { }
export class DESBlockCipher extends BlockCipher { }
export class TripleDESBlockCipher extends BlockCipher {
constructor(key: Uint8Array | Array<Uint8Array>);
}
export class IDEABlockCipher extends BlockCipher { }
const blockCipherList: Array<typeof BlockCipher>;
const getBLockCipher: (string) => (typeof BlockCipher)?;
}
export declare namespace cipherMode {
abstract class CipherMode {
/**
* the name of current block cipher mode
*/
static title: string;
/**
* construct block cipher mode with an underalying block cipher
*
* @param BlockCipher underlaying block cipher
* @param key key used in the cipher
* @param iv initialization vector
*/
constructor(BlockCipher: typeof blockCipher.BlockCipher, key: Uint8Array, iv: Uint8Array);
/**
* encrypt message using current cipher
*
* @argument msg message to be encrypted
* @returns encryption result
*/
encrypt: (msg: Uint8Array) => Uint8Array;
/**
* decrypt message using current cipher
*
* @argument cipher cipher text
* @returns decrypted plain message
*/
decrypt: (cipher: Uint8Array) => Uint8Array;
}
}
export declare namespace streamCipher {
abstract class StreamCipher {
/**
* the name of current stream cipher
*/
static title: string;
/**
* construct lock cipher using key
* @param key key used in the cipher
*/
constructor(key: Uint8Array);
/**
* get a bit stream generated from current key
*
*/
get stream(): { next: () => ({ done: boolean, value: number }) };
/**
* encrypt message using current cipher
*
* @argument msg message to be encrypted
* @returns encryption result
*/
encrypt: (msg: Uint8Array) => Uint8Array;
/**
* decrypt message using current cipher
*
* @argument cipher cipher text
* @returns decrypted plain message
*/
decrypt: (cipher: Uint8Array) => Uint8Array;
}
export class RC4StreamCipher extends StreamCipher { }
const streamCipherList: Array<typeof StreamCipher>;
const getStreamCipher: (name: string) => (typeof StreamCipher)?;
}
export declare namespace hash {
abstract class Hash {
/**
* the name of current hash method
*/
static title: string;
/**
* feed more data segment to hash
* @param data a segment of data
*/
feedData(data: Uint8Array): void;
/**
* feed the last section of data
*
* After invocation to this method, hash result is returned
* and the inner state of the hash object is reset.
*
* @param data the last segment of data (optional)
* @returns the hash result of all message segment
*/
endData(data?: Uint8Array): Uint8Array;
/**
* reset the inner state of current hash object
*/
reset(): void;
/**
* quick method to genrate hash usint current hash object
*
* if current hash object is not clean (in process of generating
* hash of a serial data segment), a new temporary hash object
* with same initialization parameter is created.
*
* @param data full message to be used to generate hash
* @returns the hash of data
*/
hash(data: Uint8Array): Uint8Array;
/**
* quick method to genrate hash usint current hash object
*
* @param data full message to be used to generate hash
* @returns the hash of data
*/
static hash(data: Uint8Array): Uint8Array;
}
export class MD2Hash extends Hash { }
export class MD4Hash extends Hash { }
export class MD5Hash extends Hash { }
export class RIPEMD128Hash extends Hash { }
export class RIPEMD160Hash extends Hash { }
export class RIPEMD256Hash extends Hash { }
export class RIPEMD320Hash extends Hash { }
export class SHA1Hash extends Hash { }
export class SHA224Hash extends Hash { }
export class SHA256Hash extends Hash { }
export class SHA384Hash extends Hash { }
export class SHA512Hash extends Hash { }
export class SHA512t224Hash extends Hash { }
export class SHA512t256Hash extends Hash { }
export class SHA512THash extends Hash {
constructor(t: number);
static hash(data: Uint8Array, t: number): Uint8Array;
}
export class SHA3_224Hash extends Hash { }
export class SHA3_256Hash extends Hash { }
export class SHA3_384Hash extends Hash { }
export class SHA3_512Hash extends Hash { }
export class SHAKE128Hash extends Hash {
constructor(d: number);
static hash(data: Uint8Array, d: number): Uint8Array;
}
export class SHAKE256Hash extends Hash {
constructor(d: number);
static hash(data: Uint8Array, d: number): Uint8Array;
}
export class Hmac extends Hash {
constructor(hashInst: Hash, blockLength: number, key: Uint8Array);
static hash(data: Uint8Array, hashInst: Hash, blockLength: number, key: Uint8Array): Uint8Array;
}
abstract class HmacClass extends Hash {
constructor(key: Uint8Array);
static hash(data: Uint8Array, key: Uint8Array): Uint8Array;
}
export class HmacMD5 extends HmacClass { }
export class HmacSHA1 extends HmacClass { }
export class HmacSHA224 extends HmacClass { }
export class HmacSHA256 extends HmacClass { }
export class HmacSHA384 extends HmacClass { }
export class HmacSHA512 extends HmacClass { }
const hashList: Array<typeof Hash>;
const getHash: (name: string) => (typeof Hash)?;
}
}
export default cryptwist;