Skip to content

Commit 77585ad

Browse files
committed
refactor: update password-hash api
1 parent 078104c commit 77585ad

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

lib/commands/generate/password-hash/create.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export default class extends Command {
4343
"description": "(scrypt) Block size parameter.",
4444
"schema": { "type": "integer", "minimum": 2 },
4545
},
46+
"max-memory": {
47+
"short": "m",
48+
"description": "(scrypt) Max memory parameter.",
49+
"schema": { "type": "integer", "minimum": 1 },
50+
},
4651
"iterations": {
4752
"short": "i",
4853
"description": "(pbkdf2) Iterations parameter.",
@@ -79,11 +84,12 @@ export default class extends Command {
7984
"parallelism": process.cli.options[ "parallelism" ],
8085
"cost": process.cli.options[ "cost" ],
8186
"blockSize": process.cli.options[ "block-size" ],
87+
"maxMemory": process.cli.options[ "max-memory" ],
8288
"iterations": process.cli.options[ "iterations" ],
8389
"saltLength": process.cli.options[ "salt-length" ],
8490
"hashLength": process.cli.options[ "hash-length" ],
8591
} ),
86-
res = await passwordHash.createHash( process.cli.arguments.password );
92+
res = await passwordHash.createPasswordHash( process.cli.arguments.password );
8793

8894
if ( res.ok ) {
8995
console.log( res.data.phc );

lib/commands/generate/password-hash/verify.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export default class extends Command {
4343
"description": "(scrypt) Block size parameter.",
4444
"schema": { "type": "integer", "minimum": 2 },
4545
},
46+
"max-memory": {
47+
"short": "m",
48+
"description": "(scrypt) Max memory parameter.",
49+
"schema": { "type": "integer", "minimum": 1 },
50+
},
4651
"iterations": {
4752
"short": "i",
4853
"description": "(pbkdf2) Iterations parameter.",
@@ -74,9 +79,10 @@ export default class extends Command {
7479
"parallelism": process.cli.options[ "parallelism" ],
7580
"cost": process.cli.options[ "cost" ],
7681
"blockSize": process.cli.options[ "block-size" ],
82+
"maxMemory": process.cli.options[ "max-memory" ],
7783
"iterations": process.cli.options[ "iterations" ],
7884
} ),
79-
res = await passwordHash.verifyHash( process.cli.arguments.digest, process.cli.arguments.password, { "update": true } );
85+
res = await passwordHash.verifyPasswordHash( process.cli.arguments.digest, process.cli.arguments.password, { "update": true } );
8086

8187
console.log( "Hash is valid:", res.ok );
8288

0 commit comments

Comments
 (0)