-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
51 lines (44 loc) · 2.15 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
declare namespace bcrypt {
/**
* @param rounds the cost of processing the data. (default - 10)
* @param cb a callback to be fired once the salt has been generated. uses eio making it asynchronous.
*/
export function genSalt (rounds?: number): Promise<string>;
export function genSalt (cb: (err: Error | null, salt: string) => void): void;
export function genSalt (rounds: number, cb: (err: Error | null, salt: string) => void): void;
/**
* @param data the data to be encrypted.
* @param salt the salt to be used to hash the password. if specified as a number then a salt will be generated with the specified number of rounds and used.
* @param cb a callback to be fired once the data has been encrypted. uses eio making it asynchronous.
*/
export function hash (data: string, salt: string | number): Promise<string>;
export function hash (data: string, salt: string | number, cb: (err: Error | null, encrypted: string) => void): void;
/**
* @param data data to compare.
* @param encrypted data to be compared to.
* @param cb a callback to be fired once the data has been compared. uses eio making it asynchronous.
*/
export function compare (data: string, encrypted: string): Promise<boolean>;
export function compare (data: string, encrypted: string, cb: (err: Error | null, same: boolean) => void): void;
/**
* @param rounds the cost of processing the data. (default - 10)
*/
export function genSaltSync (rounds?: number): string;
/**
* @param data the data to be encrypted.
* @param salt the salt to be used to hash the password. if specified as a number then a salt will be generated with the specified number of rounds and used.
*/
export function hashSync (data: string, salt: string | number): string;
/**
* @param data data to compare.
* @param encrypted data to be compared to.
*/
export function compareSync (data: string, encrypted: string): boolean;
/**
* Return the number of rounds used to encrypt a given hash.
*
* @param encrypted hash from which the number of rounds used should be extracted.
*/
export function getRounds (encrypted: string): number;
}
export = bcrypt;