UNPKG

4.3 kBTypeScriptView Raw
1type Message = string | number[] | ArrayBuffer | Uint8Array;
2
3interface 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
37interface 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
58interface 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
83interface CshakeHash {
84 /**
85 * Hash and return hex string.
86 *
87 * @param message The message you want to hash.
88 * @param outputBits The length of output.
89 * @param functionName The function name string.
90 * @param customization The customization string.
91 */
92 (message: Message, outputBits: number, functionName: Message, customization: Message): string;
93
94 /**
95 * Create a hash object.
96 *
97 * @param outputBits The length of output.
98 * @param functionName The function name string.
99 * @param customization The customization string.
100 */
101 create(outputBits: number, functionName: Message, customization: Message): Hasher;
102
103 /**
104 * Create a hash object and hash message.
105 *
106 * @param message The message you want to hash.
107 * @param outputBits The length of output.
108 * @param functionName The function name string.
109 * @param customization The customization string.
110 */
111 update(message: Message, outputBits: number, functionName: Message, customization: Message): Hasher;
112}
113
114interface KmacHash {
115 /**
116 * Hash and return hex string.
117 *
118 * @param key The key string.
119 * @param message The message you want to hash.
120 * @param outputBits The length of output.
121 * @param customization The customization string.
122 */
123 (key: Message, message: Message, outputBits: number, customization: Message): string;
124
125 /**
126 * Create a hash object.
127 *
128 * @param key The key string.
129 * @param outputBits The length of output.
130 * @param customization The customization string.
131 */
132 create(key: Message, outputBits: number, customization: Message): Hasher;
133
134 /**
135 * Create a hash object and hash message.
136 *
137 * @param key The key string.
138 * @param message The message you want to hash.
139 * @param outputBits The length of output.
140 * @param customization The customization string.
141 */
142 update(key: Message, message: Message, outputBits: number, customization: Message): Hasher;
143}
144
145export var sha3_512: Hash;
146export var sha3_384: Hash;
147export var sha3_256: Hash;
148export var sha3_224: Hash;
149export var keccak_512: Hash;
150export var keccak_384: Hash;
151export var keccak_256: Hash;
152export var keccak_224: Hash;
153export var keccak512: Hash;
154export var keccak384: Hash;
155export var keccak256: Hash;
156export var keccak224: Hash;
157export var shake_128: ShakeHash;
158export var shake_256: ShakeHash;
159export var shake128: ShakeHash;
160export var shake256: ShakeHash;
161export var cshake_128: CshakeHash;
162export var cshake_256: CshakeHash;
163export var cshake128: CshakeHash;
164export var cshake256: CshakeHash;
165export var kmac_128: KmacHash;
166export var kmac_256: KmacHash;
167export var kmac128: KmacHash;
168export var kmac256: KmacHash;