forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bcrypt.d.ts
65 lines (58 loc) · 2.6 KB
/
bcrypt.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Type definitions for bcrypt
// Project: https://www.npmjs.org/package/bcrypt
// Definitions by: Peter Harris <https://github.com/codeanimal>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "bcrypt" {
/**
* @param rounds The cost of processing the data. Default 10.
*/
export function genSaltSync(rounds?: number): string;
/**
* @param rounds The cost of processing the data. Default 10.
* @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous.
*/
export function genSalt(rounds: number, callback: (err: Error, salt: string) => void): void;
/**
* @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous.
*/
export function genSalt(callback: (err: Error, salt: string) => void): void;
/**
* @param data The data to be encrypted.
* @param salt The salt to be used in encryption.
*/
export function hashSync(data: any, salt: string): string;
/**
* @param data The data to be encrypted.
* @param rounds A salt will be generated using the rounds specified.
*/
export function hashSync(data: any, rounds: number): string;
/**
* @param data The data to be encrypted.
* @param salt The salt to be used in encryption.
* @param callback A callback to be fired once the data has been encrypted. Uses eio making it asynchronous.
*/
export function hash(data: any, salt: string, callback: (err: Error, encrypted: string) => void): void;
/**
* @param data The data to be encrypted.
* @param rounds A salt will be generated using the rounds specified.
* @param callback A callback to be fired once the data has been encrypted. Uses eio making it asynchronous.
*/
export function hash(data: any, rounds: number, callback: (err: Error, encrypted: string) => void): void;
/**
* @param data The data to be encrypted.
* @param encrypted The data to be compared against.
*/
export function compareSync(data: any, encrypted: string): boolean;
/**
* @param data The data to be encrypted.
* @param encrypted The data to be compared against.
* @param callback A callback to be fire once the data has been compared. Uses eio making it asynchronous.
*/
export function compare(data: any, encrypted: string, callback: (err: Error, same: boolean) => void): void;
/**
* 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;
}