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,43 +9,53 @@ 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 ) } ,
15- } ,
16- "id" : {
17- "short" : "i" ,
18- "description" : "Argon2 algorithm id." ,
19- "schema" : { "enum" : [ "argon2d" , "argon2i" , "argon2id" ] } ,
12+ "description" : "Preset." ,
13+ "default" : PasswordHash . defaultPreset ,
14+ "schema" : { "enum" : Object . keys ( PasswordHash . presets ) } ,
2015 } ,
2116 "argon2-version" : {
2217 "short" : "v" ,
23- "description" : "Argon2 algorithm version." ,
18+ "description" : "(argon2) Algorithm version." ,
2419 "schema" : { "enum" : [ 16 , 19 ] } ,
2520 } ,
2621 "memory-cost" : {
2722 "short" : "m" ,
28- "description" : "Argon2 memory cost parameter in KiB." ,
23+ "description" : "(argon2) Memory cost parameter in KiB." ,
2924 "schema" : { "type" : "integer" , "minimum" : 1 , "maximum" : 2 ** 32 - 1 } ,
3025 } ,
3126 "time-cost" : {
3227 "short" : "t" ,
33- "description" : "Argon2 time cost parameter." ,
28+ "description" : "(argon2) Time cost parameter." ,
3429 "schema" : { "type" : "integer" , "minimum" : 1 , "maximum" : 2 ** 32 - 1 } ,
3530 } ,
3631 "parallelism" : {
3732 "short" : "p" ,
38- "description" : "Argon2 parallelism parameter." ,
33+ "description" : "(argon2, scrypt) Parallelism parameter." ,
3934 "schema" : { "type" : "integer" , "minimum" : 1 , "maximum" : 255 } ,
4035 } ,
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+ } ,
4151 "salt-length" : {
4252 "short" : "s" ,
43- "description" : "Argon2 salt length." ,
53+ "description" : "Salt length." ,
4454 "schema" : { "type" : "integer" , "minimum" : 8 , "maximum" : 48 } ,
4555 } ,
4656 "hash-length" : {
4757 "short" : "h" ,
48- "description" : "Argon2 hash length." ,
58+ "description" : "Hash length." ,
4959 "schema" : { "type" : "integer" , "minimum" : 12 , "maximum" : 64 } ,
5060 } ,
5161 } ,
@@ -61,18 +71,20 @@ export default class extends Command {
6171
6272 // public
6373 async run ( ) {
64- const argon2 = new Argon2 ( {
74+ const passwordHash = new PasswordHash ( {
6575 "preset" : process . cli . options . preset ,
66- "id" : process . cli . options . id ,
6776 "version" : process . cli . options [ "argon2-version" ] ,
6877 "memoryCost" : process . cli . options [ "memory-cost" ] ,
6978 "timeCost" : process . cli . options [ "time-cost" ] ,
7079 "parallelism" : process . cli . options [ "parallelism" ] ,
80+ "cost" : process . cli . options [ "cost" ] ,
81+ "blockSize" : process . cli . options [ "block-size" ] ,
82+ "iterations" : process . cli . options [ "iterations" ] ,
7183 "saltLength" : process . cli . options [ "salt-length" ] ,
7284 "hashLength" : process . cli . options [ "hash-length" ] ,
7385 } ) ,
74- hash = await argon2 . createHash ( process . cli . arguments . password ) ;
86+ hash = await passwordHash . createHash ( process . cli . arguments . password ) ;
7587
76- console . log ( hash ) ;
88+ console . log ( hash . phc ) ;
7789 }
7890}
0 commit comments