1- import Argon2 from "#core/argon2 " ;
1+ import PasswordHash from "#core/crypto/password-hash " ;
22import Command from "#lib/command" ;
33
44export default class extends Command {
@@ -9,30 +9,45 @@ export default class extends Command {
99 "options" : {
1010 "preset" : {
1111 "short" : "P" ,
12- "description" : "Argon2 preset ." ,
13- "default" : Argon2 . defaultPreset ,
14- "schema" : { "enum" : Object . keys ( Argon2 . presets ) } ,
12+ "description" : "Preset ." ,
13+ "default" : PasswordHash . defaultPreset ,
14+ "schema" : { "enum" : Object . keys ( PasswordHash . presets ) } ,
1515 } ,
1616 "argon2-version" : {
1717 "short" : "v" ,
18- "description" : "Argon2 algorithm version." ,
18+ "description" : "(argon2) Algorithm version." ,
1919 "schema" : { "enum" : [ 16 , 19 ] } ,
2020 } ,
2121 "memory-cost" : {
2222 "short" : "m" ,
23- "description" : "Argon2 memory cost parameter in KiB." ,
23+ "description" : "(argon2) Memory cost parameter in KiB." ,
2424 "schema" : { "type" : "integer" , "minimum" : 1 , "maximum" : 2 ** 32 - 1 } ,
2525 } ,
2626 "time-cost" : {
2727 "short" : "t" ,
28- "description" : "Argon2 time cost parameter." ,
28+ "description" : "(argon2) Time cost parameter." ,
2929 "schema" : { "type" : "integer" , "minimum" : 1 , "maximum" : 2 ** 32 - 1 } ,
3030 } ,
3131 "parallelism" : {
3232 "short" : "p" ,
33- "description" : "Argon2 parallelism parameter." ,
33+ "description" : "(argon2, scrypt) Parallelism parameter." ,
3434 "schema" : { "type" : "integer" , "minimum" : 1 , "maximum" : 255 } ,
3535 } ,
36+ "cost" : {
37+ "short" : "c" ,
38+ "description" : "(scrypt) Cost parameter." ,
39+ "schema" : { "type" : "integer" , "minimum" : 2 } ,
40+ } ,
41+ "block-size" : {
42+ "short" : "b" ,
43+ "description" : "(scrypt) Block size parameter." ,
44+ "schema" : { "type" : "integer" , "minimum" : 2 } ,
45+ } ,
46+ "iterations" : {
47+ "short" : "i" ,
48+ "description" : "(pbkdf2) Iterations parameter." ,
49+ "schema" : { "type" : "integer" , "minimum" : 1 } ,
50+ } ,
3651 } ,
3752 "arguments" : {
3853 "password" : {
@@ -51,19 +66,20 @@ export default class extends Command {
5166
5267 // public
5368 async run ( ) {
54- const argon2 = new Argon2 ( {
69+ const passwordHash = new PasswordHash ( {
5570 "preset" : process . cli . options . preset ,
5671 "version" : process . cli . options [ "argon2-version" ] ,
5772 "memoryCost" : process . cli . options [ "memory-cost" ] ,
5873 "timeCost" : process . cli . options [ "time-cost" ] ,
5974 "parallelism" : process . cli . options [ "parallelism" ] ,
75+ "cost" : process . cli . options [ "cost" ] ,
76+ "blockSize" : process . cli . options [ "block-size" ] ,
77+ "iterations" : process . cli . options [ "iterations" ] ,
6078 } ) ,
61- valid = await argon2 . verifyHash ( process . cli . arguments . digest , process . cli . arguments . password ) ;
79+ res = await passwordHash . verifyHash ( process . cli . arguments . digest , process . cli . arguments . password ) ;
6280
63- console . log ( "Hash is valid:" , valid ) ;
81+ console . log ( "Hash is valid:" , res . ok ) ;
6482
65- return valid
66- ? result ( 200 )
67- : result ( 400 ) ;
83+ return res ;
6884 }
6985}
0 commit comments