UNPKG

980 BTypeScriptView Raw
1// Type definitions for sha1 1.1
2// Project: https://github.com/pvorb/node-sha1
3// Definitions by: Bill Sourour <https://github.com/arcdev1>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/// <reference types="node" />
7
8/**
9 * js function for hashing messages with SHA1
10 *
11 * @param message - a string or buffer to hash
12 * @param options - an options object
13 * @returns the resultant SHA1 hash of the given message
14 */
15declare function main(message: string | Buffer, options?: Sha1AsStringOptions): string;
16declare function main(message: string | Buffer, options?: Sha1AsBytesOptions): Uint8Array;
17declare function main(message: string | Buffer, options?: Sha1Options): string | Uint8Array;
18export = main;
19
20interface Sha1AsStringOptions {
21 asBytes?: false | undefined;
22 asString?: boolean | undefined;
23}
24
25interface Sha1AsBytesOptions {
26 asBytes: true;
27 asString?: false | undefined;
28}
29
30type Sha1Options = Sha1AsStringOptions | Sha1AsBytesOptions;