mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Merge pull request #26848 from Flarna/node_add_crpyto_scrypt
[node] add crypto.scrypt and crypto.scryptSync
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@
|
||||
"scripts": {
|
||||
"compile-scripts": "tsc -p scripts",
|
||||
"not-needed": "node scripts/not-needed.js",
|
||||
"test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed",
|
||||
"test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed --nProcesses 2",
|
||||
"lint": "dtslint types"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Vendored
+11
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Node.js 10.3.x
|
||||
// Type definitions for Node.js 10.5.x
|
||||
// Project: http://nodejs.org/
|
||||
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>
|
||||
// DefinitelyTyped <https://github.com/DefinitelyTyped/DefinitelyTyped>
|
||||
@@ -5899,6 +5899,16 @@ declare module "crypto" {
|
||||
export function randomFill(buffer: ArrayBufferView, offset: number, callback: (err: Error | null, buf: ArrayBufferView) => void): void;
|
||||
export function randomFill(buffer: ArrayBufferView, offset: number, size: number, callback: (err: Error | null, buf: ArrayBufferView) => void): void;
|
||||
|
||||
export interface ScryptOptions {
|
||||
N?: number;
|
||||
r?: number;
|
||||
p?: number;
|
||||
maxmem?: number;
|
||||
}
|
||||
export function scrypt(password: string | ArrayBufferView, salt: string | ArrayBufferView, keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void): void;
|
||||
export function scrypt(password: string | ArrayBufferView, salt: string | ArrayBufferView, keylen: number, options: ScryptOptions, callback: (err: Error | null, derivedKey: Buffer) => void): void;
|
||||
export function scryptSync(password: string | ArrayBufferView, salt: string | ArrayBufferView, keylen: number, options?: ScryptOptions): Buffer;
|
||||
|
||||
export interface RsaPublicKey {
|
||||
key: string;
|
||||
padding?: number;
|
||||
|
||||
@@ -1263,6 +1263,24 @@ namespace crypto_tests {
|
||||
crypto.randomFill(i32arr, 2, 3, (err: Error, buf: ArrayBufferView) => void {});
|
||||
}
|
||||
|
||||
{
|
||||
// scrypt
|
||||
const pwd: string | Buffer | Int32Array | DataView = Buffer.alloc(16);
|
||||
const salt: string | Buffer | Int32Array | DataView = Buffer.alloc(16);
|
||||
crypto.scrypt(pwd, salt, 64, (err: Error | null, derivedKey: Buffer): void => {});
|
||||
const opts: crypto.ScryptOptions = {
|
||||
N: 16384,
|
||||
r: 8,
|
||||
p: 1,
|
||||
maxmem: 32 * 1024 * 1024
|
||||
};
|
||||
crypto.scrypt(pwd, salt, 64, opts, (err: Error | null, derivedKey: Buffer): void => {});
|
||||
crypto.scrypt(pwd, salt, 64, { maxmem: 16 * 1024 * 1024 }, (err: Error | null, derivedKey: Buffer): void => {});
|
||||
let buf: Buffer = crypto.scryptSync(pwd, salt, 64);
|
||||
buf = crypto.scryptSync(pwd, salt, 64, opts);
|
||||
buf = crypto.scryptSync(pwd, salt, 64, { N: 1024 });
|
||||
}
|
||||
|
||||
{
|
||||
let key: string | Buffer = Buffer.from("buf");
|
||||
let curve = "secp256k1";
|
||||
|
||||
Reference in New Issue
Block a user