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 | * Create a hash object.
|
47 | */
|
48 | create(): Hasher;
|
49 |
|
50 | /**
|
51 | * Create a hash object and hash message.
|
52 | *
|
53 | * @param message The message you want to hash.
|
54 | */
|
55 | update(message: Message): Hasher;
|
56 | }
|
57 |
|
58 | interface ShakeHash {
|
59 | /**
|
60 | * Hash and return hex string.
|
61 | *
|
62 | * @param message The message you want to hash.
|
63 | * @param outputBits The length of output.
|
64 | */
|
65 | (message: Message, outputBits: number): string;
|
66 |
|
67 | /**
|
68 | * Create a hash object.
|
69 | *
|
70 | * @param outputBits The length of output.
|
71 | */
|
72 | create(outputBits: number): Hasher;
|
73 |
|
74 | /**
|
75 | * Create a hash object and hash message.
|
76 | *
|
77 | * @param message The message you want to hash.
|
78 | * @param outputBits The length of output.
|
79 | */
|
80 | update(message: Message, outputBits: number): Hasher;
|
81 | }
|
82 |
|
83 | export var sha3_512: Hash;
|
84 | export var sha3_384: Hash;
|
85 | export var sha3_256: Hash;
|
86 | export var sha3_224: Hash;
|
87 | export var keccak_512: Hash;
|
88 | export var keccak_384: Hash;
|
89 | export var keccak_256: Hash;
|
90 | export var keccak_224: Hash;
|
91 | export var shake_128: ShakeHash;
|
92 | export var shake_256: ShakeHash;
|