|
1 | 1 | declare namespace md5 { |
2 | | - type message = string | any[] | Uint8Array | ArrayBuffer; |
3 | | - |
4 | | - interface Md5 { |
5 | | - array(): number[]; |
6 | | - arrayBuffer(): ArrayBuffer; |
7 | | - buffer(): ArrayBuffer; |
8 | | - digest(): number[]; |
9 | | - hex(): string; |
10 | | - toString(): string; |
11 | | - update(message: message): Md5; |
12 | | - base64(): string; |
13 | | - } |
14 | | - |
15 | | - interface md5 { |
16 | | - (message: message): string; |
17 | | - hex(message: message): string; |
18 | | - array(message: message): number[]; |
19 | | - digest(message: message): number[]; |
20 | | - arrayBuffer(message: message): ArrayBuffer; |
21 | | - buffer(message: message): ArrayBuffer; |
22 | | - create(): Md5; |
23 | | - update(message: message): Md5; |
24 | | - base64(message: message): string; |
25 | | - } |
| 2 | + type Message = string | number[] | ArrayBuffer | Uint8Array; |
| 3 | + |
| 4 | + interface Hasher { |
| 5 | + /** |
| 6 | + * Update hash |
| 7 | + * |
| 8 | + * @param message The message you want to hash. |
| 9 | + */ |
| 10 | + update(message: Message): Hasher; |
| 11 | + |
| 12 | + /** |
| 13 | + * Return hash in hex string. |
| 14 | + */ |
| 15 | + hex(): string; |
| 16 | + |
| 17 | + /** |
| 18 | + * Return hash in hex string. |
| 19 | + */ |
| 20 | + toString(): string; |
| 21 | + |
| 22 | + /** |
| 23 | + * Return hash in ArrayBuffer. |
| 24 | + */ |
| 25 | + arrayBuffer(): ArrayBuffer; |
| 26 | + |
| 27 | + /** |
| 28 | + * Return hash in integer array. |
| 29 | + */ |
| 30 | + digest(): number[]; |
| 31 | + |
| 32 | + /** |
| 33 | + * Return hash in integer array. |
| 34 | + */ |
| 35 | + array(): number[]; |
| 36 | + |
| 37 | + /** |
| 38 | + * Return hash in base64 string. |
| 39 | + */ |
| 40 | + base64(): string; |
| 41 | + } |
| 42 | + |
| 43 | + interface Hmac { |
| 44 | + /** |
| 45 | + * Computes a Hash-based message authentication code (HMAC) using a secret key |
| 46 | + * |
| 47 | + * @param secretKey The Secret Key |
| 48 | + * @param message The message you want to hash. |
| 49 | + */ |
| 50 | + (secretKey: Message, message: Message): string; |
| 51 | + |
| 52 | + /** |
| 53 | + * Create a hash object using a secret key. |
| 54 | + * |
| 55 | + * @param secretKey The Secret Key |
| 56 | + */ |
| 57 | + create(secretKey: Message): Hasher; |
| 58 | + |
| 59 | + /** |
| 60 | + * Create a hash object and hash message using a secret key |
| 61 | + * |
| 62 | + * @param secretKey The Secret Key |
| 63 | + * @param message The message you want to hash. |
| 64 | + */ |
| 65 | + update(secretKey: Message, message: Message): Hasher; |
| 66 | + |
| 67 | + /** |
| 68 | + * Return hash in hex string. |
| 69 | + * |
| 70 | + * @param secretKey The Secret Key |
| 71 | + * @param message The message you want to hash. |
| 72 | + */ |
| 73 | + hex(secretKey: Message, message: Message): string; |
| 74 | + |
| 75 | + /** |
| 76 | + * Return hash in ArrayBuffer. |
| 77 | + * |
| 78 | + * @param secretKey The Secret Key |
| 79 | + * @param message The message you want to hash. |
| 80 | + */ |
| 81 | + arrayBuffer(secretKey: Message, message: Message): ArrayBuffer; |
| 82 | + |
| 83 | + /** |
| 84 | + * Return hash in integer array. |
| 85 | + * |
| 86 | + * @param secretKey The Secret Key |
| 87 | + * @param message The message you want to hash. |
| 88 | + */ |
| 89 | + digest(secretKey: Message, message: Message): number[]; |
| 90 | + |
| 91 | + /** |
| 92 | + * Return hash in integer array. |
| 93 | + * |
| 94 | + * @param secretKey The Secret Key |
| 95 | + * @param message The message you want to hash. |
| 96 | + */ |
| 97 | + array(secretKey: Message, message: Message): number[]; |
| 98 | + |
| 99 | + /** |
| 100 | + * Return hash in base64 string. |
| 101 | + * |
| 102 | + * @param secretKey The Secret Key |
| 103 | + * @param message The message you want to hash. |
| 104 | + */ |
| 105 | + base64(secretKey: Message, message: Message): string; |
| 106 | + } |
| 107 | + |
| 108 | + interface Hash { |
| 109 | + /** |
| 110 | + * Hash and return hex string. |
| 111 | + * |
| 112 | + * @param message The message you want to hash. |
| 113 | + */ |
| 114 | + (message: Message): string; |
| 115 | + |
| 116 | + /** |
| 117 | + * Create a hash object. |
| 118 | + */ |
| 119 | + create(): Hasher; |
| 120 | + |
| 121 | + /** |
| 122 | + * Create a hash object and hash message. |
| 123 | + * |
| 124 | + * @param message The message you want to hash. |
| 125 | + */ |
| 126 | + update(message: Message): Hasher; |
| 127 | + |
| 128 | + /** |
| 129 | + * Return hash in hex string. |
| 130 | + * |
| 131 | + * @param message The message you want to hash. |
| 132 | + */ |
| 133 | + hex(message: Message): string; |
| 134 | + |
| 135 | + /** |
| 136 | + * Return hash in ArrayBuffer. |
| 137 | + * |
| 138 | + * @param message The message you want to hash. |
| 139 | + */ |
| 140 | + arrayBuffer(message: Message): ArrayBuffer; |
| 141 | + |
| 142 | + /** |
| 143 | + * Return hash in integer array. |
| 144 | + * |
| 145 | + * @param message The message you want to hash. |
| 146 | + */ |
| 147 | + digest(message: Message): number[]; |
| 148 | + |
| 149 | + /** |
| 150 | + * Return hash in integer array. |
| 151 | + * |
| 152 | + * @param message The message you want to hash. |
| 153 | + */ |
| 154 | + array(message: Message): number[]; |
| 155 | + |
| 156 | + /** |
| 157 | + * Return hash in base64 string. |
| 158 | + * |
| 159 | + * @param message The message you want to hash. |
| 160 | + */ |
| 161 | + base64(message: Message): string; |
| 162 | + |
| 163 | + /** |
| 164 | + * HMAC interface |
| 165 | + */ |
| 166 | + hmac: Hmac; |
| 167 | + } |
26 | 168 | } |
27 | 169 |
|
28 | | -declare const md5: md5.md5; |
| 170 | +declare const md5: md5.Hash; |
29 | 171 | export = md5; |
0 commit comments