-
-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathindex.d.ts
More file actions
63 lines (58 loc) · 1.95 KB
/
index.d.ts
File metadata and controls
63 lines (58 loc) · 1.95 KB
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
/// <reference types="node" />
/**
* Input type for password and salt parameters.
* Accepts strings, Buffers, Uint8Arrays, and ArrayBufferViews (e.g. DataView).
*/
type BinaryLike = string | Buffer | Uint8Array | ArrayBufferView;
/**
* Asynchronously derives a key using PBKDF2.
*
* @param password - The password to derive the key from.
* @param salt - The cryptographic salt.
* @param iterations - The number of iterations to perform.
* @param keylen - The desired length of the derived key in bytes.
* @param digest - The HMAC digest algorithm to use (e.g. `'sha1'`, `'sha256'`, `'sha512'`).
* @param callback - Called with `(err, derivedKey)` upon completion.
*/
declare function pbkdf2(
password: BinaryLike,
salt: BinaryLike,
iterations: number,
keylen: number,
digest: string,
callback: (err: Error | null, derivedKey: Buffer) => void,
): void;
/**
* Asynchronously derives a key using PBKDF2, defaulting to `'sha1'` digest.
*
* @param password - The password to derive the key from.
* @param salt - The cryptographic salt.
* @param iterations - The number of iterations to perform.
* @param keylen - The desired length of the derived key in bytes.
* @param callback - Called with `(err, derivedKey)` upon completion.
*/
declare function pbkdf2(
password: BinaryLike,
salt: BinaryLike,
iterations: number,
keylen: number,
callback: (err: Error | null, derivedKey: Buffer) => void,
): void;
/**
* Synchronously derives a key using PBKDF2.
*
* @param password - The password to derive the key from.
* @param salt - The cryptographic salt.
* @param iterations - The number of iterations to perform.
* @param keylen - The desired length of the derived key in bytes.
* @param digest - The HMAC digest algorithm to use (defaults to `'sha1'`).
* @returns The derived key as a Buffer.
*/
declare function pbkdf2Sync(
password: BinaryLike,
salt: BinaryLike,
iterations: number,
keylen: number,
digest?: string,
): Buffer;
export { pbkdf2, pbkdf2Sync };