1 | type Message = string | number[] | ArrayBuffer | Uint8Array;
|
2 |
|
3 | interface Hasher {
|
4 | /**
|
5 | * Update hash
|
6 | *
|
7 | * @param message The message you want to hash.
|
8 | */
|
9 | update(message: Message): Hasher;
|
10 |
|
11 | /**
|
12 | * Return hash in hex string.
|
13 | */
|
14 | hex(): string;
|
15 |
|
16 | /**
|
17 | * Return hash in hex string.
|
18 | */
|
19 | toString(): string;
|
20 |
|
21 | /**
|
22 | * Return hash in ArrayBuffer.
|
23 | */
|
24 | arrayBuffer(): ArrayBuffer;
|
25 |
|
26 | /**
|
27 | * Return hash in integer array.
|
28 | */
|
29 | digest(): number[];
|
30 |
|
31 | /**
|
32 | * Return hash in integer array.
|
33 | */
|
34 | array(): number[];
|
35 | }
|
36 |
|
37 | interface Hash {
|
38 | /**
|
39 | * Hash and return hex string.
|
40 | *
|
41 | * @param message The message you want to hash.
|
42 | */
|
43 | (message: Message): string;
|
44 |
|
45 | /**
|
46 | * Hash and return hex string.
|
47 | *
|
48 | * @param message The message you want to hash.
|
49 | */
|
50 | hex(message: Message): string;
|
51 |
|
52 | /**
|
53 | * Hash and return ArrayBuffer.
|
54 | *
|
55 | * @param message The message you want to hash.
|
56 | */
|
57 | arrayBuffer(message: Message): ArrayBuffer;
|
58 |
|
59 | /**
|
60 | * Hash and return integer array.
|
61 | *
|
62 | * @param message The message you want to hash.
|
63 | */
|
64 | digest(message: Message): number[];
|
65 |
|
66 | /**
|
67 | * Hash and return integer array.
|
68 | *
|
69 | * @param message The message you want to hash.
|
70 | */
|
71 | array(message: Message): number[];
|
72 |
|
73 | /**
|
74 | * Create a hash object.
|
75 | */
|
76 | create(): Hasher;
|
77 |
|
78 | /**
|
79 | * Create a hash object and hash message.
|
80 | *
|
81 | * @param message The message you want to hash.
|
82 | */
|
83 | update(message: Message): Hasher;
|
84 | }
|
85 |
|
86 | interface ShakeHash {
|
87 | /**
|
88 | * Hash and return hex string.
|
89 | *
|
90 | * @param message The message you want to hash.
|
91 | * @param outputBits The length of output.
|
92 | */
|
93 | (message: Message, outputBits: number): string;
|
94 |
|
95 | /**
|
96 | * Hash and return hex string.
|
97 | *
|
98 | * @param message The message you want to hash.
|
99 | * @param outputBits The length of output.
|
100 | */
|
101 | hex(message: Message, outputBits: number): string;
|
102 |
|
103 | /**
|
104 | * Hash and return ArrayBuffer.
|
105 | *
|
106 | * @param message The message you want to hash.
|
107 | * @param outputBits The length of output.
|
108 | */
|
109 | arrayBuffer(message: Message, outputBits: number): ArrayBuffer;
|
110 |
|
111 | /**
|
112 | * Hash and return integer array.
|
113 | *
|
114 | * @param message The message you want to hash.
|
115 | * @param outputBits The length of output.
|
116 | */
|
117 | digest(message: Message, outputBits: number): number[];
|
118 |
|
119 | /**
|
120 | * Hash and return integer array.
|
121 | *
|
122 | * @param message The message you want to hash.
|
123 | * @param outputBits The length of output.
|
124 | */
|
125 | array(message: Message, outputBits: number): number[];
|
126 |
|
127 | /**
|
128 | * Create a hash object.
|
129 | *
|
130 | * @param outputBits The length of output.
|
131 | * @param outputBits The length of output.
|
132 | */
|
133 | create(outputBits: number): Hasher;
|
134 |
|
135 | /**
|
136 | * Create a hash object and hash message.
|
137 | *
|
138 | * @param message The message you want to hash.
|
139 | * @param outputBits The length of output.
|
140 | */
|
141 | update(message: Message, outputBits: number): Hasher;
|
142 | }
|
143 |
|
144 | interface CshakeHash {
|
145 | /**
|
146 | * Hash and return hex string.
|
147 | *
|
148 | * @param message The message you want to hash.
|
149 | * @param outputBits The length of output.
|
150 | * @param functionName The function name string.
|
151 | * @param customization The customization string.
|
152 | */
|
153 | (message: Message, outputBits: number, functionName: Message, customization: Message): string;
|
154 |
|
155 | /**
|
156 | * Hash and return hex string.
|
157 | *
|
158 | * @param message The message you want to hash.
|
159 | * @param outputBits The length of output.
|
160 | * @param functionName The function name string.
|
161 | * @param customization The customization string.
|
162 | */
|
163 | hex(message: Message, outputBits: number, functionName: Message, customization: Message): string;
|
164 |
|
165 | /**
|
166 | * Hash and return ArrayBuffer.
|
167 | *
|
168 | * @param message The message you want to hash.
|
169 | * @param outputBits The length of output.
|
170 | * @param functionName The function name string.
|
171 | * @param customization The customization string.
|
172 | */
|
173 | arrayBuffer(message: Message, outputBits: number, functionName: Message, customization: Message): ArrayBuffer;
|
174 |
|
175 | /**
|
176 | * Hash and return integer array.
|
177 | *
|
178 | * @param message The message you want to hash.
|
179 | * @param outputBits The length of output.
|
180 | * @param functionName The function name string.
|
181 | * @param customization The customization string.
|
182 | */
|
183 | digest(message: Message, outputBits: number, functionName: Message, customization: Message): number[];
|
184 |
|
185 | /**
|
186 | * Hash and return integer array.
|
187 | *
|
188 | * @param message The message you want to hash.
|
189 | * @param outputBits The length of output.
|
190 | * @param functionName The function name string.
|
191 | * @param customization The customization string.
|
192 | */
|
193 | array(message: Message, outputBits: number, functionName: Message, customization: Message): number[];
|
194 |
|
195 | /**
|
196 | * Create a hash object.
|
197 | *
|
198 | * @param outputBits The length of output.
|
199 | * @param outputBits The length of output.
|
200 | */
|
201 | create(outputBits: number): Hasher;
|
202 |
|
203 | /**
|
204 | * Create a hash object.
|
205 | *
|
206 | * @param outputBits The length of output.
|
207 | * @param functionName The function name string.
|
208 | * @param customization The customization string.
|
209 | */
|
210 | create(outputBits: number, functionName: Message, customization: Message): Hasher;
|
211 |
|
212 | /**
|
213 | * Create a hash object and hash message.
|
214 | *
|
215 | * @param message The message you want to hash.
|
216 | * @param outputBits The length of output.
|
217 | * @param functionName The function name string.
|
218 | * @param customization The customization string.
|
219 | */
|
220 | update(message: Message, outputBits: number, functionName: Message, customization: Message): Hasher;
|
221 | }
|
222 |
|
223 | interface KmacHash {
|
224 | /**
|
225 | * Hash and return hex string.
|
226 | *
|
227 | * @param key The key string.
|
228 | * @param message The message you want to hash.
|
229 | * @param outputBits The length of output.
|
230 | * @param customization The customization string.
|
231 | */
|
232 | (key: Message, message: Message, outputBits: number, customization: Message): string;
|
233 |
|
234 | /**
|
235 | * Hash and return hex string.
|
236 | *
|
237 | * @param key The key string.
|
238 | * @param message The message you want to hash.
|
239 | * @param outputBits The length of output.
|
240 | * @param customization The customization string.
|
241 | */
|
242 | hex(key: Message, message: Message, outputBits: number, customization: Message): string;
|
243 |
|
244 | /**
|
245 | * Hash and return ArrayBuffer.
|
246 | *
|
247 | * @param key The key string.
|
248 | * @param message The message you want to hash.
|
249 | * @param outputBits The length of output.
|
250 | * @param customization The customization string.
|
251 | */
|
252 | arrayBuffer(key: Message, message: Message, outputBits: number, customization: Message): ArrayBuffer;
|
253 |
|
254 | /**
|
255 | * Hash and return integer array.
|
256 | *
|
257 | * @param key The key string.
|
258 | * @param message The message you want to hash.
|
259 | * @param outputBits The length of output.
|
260 | * @param customization The customization string.
|
261 | */
|
262 | digest(key: Message, message: Message, outputBits: number, customization: Message): number[];
|
263 |
|
264 | /**
|
265 | * Hash and return integer array.
|
266 | *
|
267 | * @param key The key string.
|
268 | * @param message The message you want to hash.
|
269 | * @param outputBits The length of output.
|
270 | * @param customization The customization string.
|
271 | */
|
272 | array(key: Message, message: Message, outputBits: number, customization: Message): number[];
|
273 |
|
274 | /**
|
275 | * Create a hash object.
|
276 | *
|
277 | * @param key The key string.
|
278 | * @param outputBits The length of output.
|
279 | * @param customization The customization string.
|
280 | */
|
281 | create(key: Message, outputBits: number, customization: Message): Hasher;
|
282 |
|
283 | /**
|
284 | * Create a hash object and hash message.
|
285 | *
|
286 | * @param key The key string.
|
287 | * @param message The message you want to hash.
|
288 | * @param outputBits The length of output.
|
289 | * @param customization The customization string.
|
290 | */
|
291 | update(key: Message, message: Message, outputBits: number, customization: Message): Hasher;
|
292 | }
|
293 |
|
294 | export var sha3_512: Hash;
|
295 | export var sha3_384: Hash;
|
296 | export var sha3_256: Hash;
|
297 | export var sha3_224: Hash;
|
298 | export var keccak_512: Hash;
|
299 | export var keccak_384: Hash;
|
300 | export var keccak_256: Hash;
|
301 | export var keccak_224: Hash;
|
302 | export var keccak512: Hash;
|
303 | export var keccak384: Hash;
|
304 | export var keccak256: Hash;
|
305 | export var keccak224: Hash;
|
306 | export var shake_128: ShakeHash;
|
307 | export var shake_256: ShakeHash;
|
308 | export var shake128: ShakeHash;
|
309 | export var shake256: ShakeHash;
|
310 | export var cshake_128: CshakeHash;
|
311 | export var cshake_256: CshakeHash;
|
312 | export var cshake128: CshakeHash;
|
313 | export var cshake256: CshakeHash;
|
314 | export var kmac_128: KmacHash;
|
315 | export var kmac_256: KmacHash;
|
316 | export var kmac128: KmacHash;
|
317 | export var kmac256: KmacHash;
|