Skip to content

Commit 9c8bcf0

Browse files
committed
feat: add argon2 hash
1 parent b4da19e commit 9c8bcf0

2 files changed

Lines changed: 24 additions & 20 deletions

File tree

lib/commands/generate/argon2/create.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,50 @@ export default class extends Command {
55

66
// static
77
static cli () {
8+
const argon2 = new Argon2();
9+
810
return {
911
"options": {
1012
"id": {
1113
"short": "i",
12-
"description": "Argon2 algorithm to use.",
13-
"default": "argon2id",
14+
"description": "Argon2 algorithm type.",
15+
"default": argon2.id,
1416
"schema": { "enum": [ "argon2d", "argon2i", "argon2id" ] },
1517
},
1618
"argon2-version": {
1719
"short": "v",
1820
"description": "Argon2 algorithm version.",
19-
"default": 19,
21+
"default": argon2.version,
2022
"schema": { "enum": [ 16, 19 ] },
2123
},
2224
"memory-cost": {
2325
"short": "m",
2426
"description": "Argon2 memory cost parameter.",
25-
"default": 65_536,
27+
"default": argon2.memoryCost,
2628
"schema": { "type": "integer", "minimum": 1, "maximum": 2 ** 32 - 1 },
2729
},
2830
"time-cost": {
2931
"short": "t",
3032
"description": "Argon2 time cost parameter.",
31-
"default": 3,
33+
"default": argon2.timeCost,
3234
"schema": { "type": "integer", "minimum": 1, "maximum": 2 ** 32 - 1 },
3335
},
3436
"parallelism": {
3537
"short": "p",
3638
"description": "Argon2 parallelism parameter.",
37-
"default": 4,
39+
"default": argon2.parallelism,
3840
"schema": { "type": "integer", "minimum": 1, "maximum": 255 },
3941
},
4042
"salt-length": {
4143
"short": "s",
42-
"description": "Argon2 salt length parameter.",
43-
"default": 16,
44+
"description": "Argon2 salt length.",
45+
"default": argon2.saltLength,
4446
"schema": { "type": "integer", "minimum": 8, "maximum": 48 },
4547
},
4648
"hash-length": {
4749
"short": "h",
48-
"description": "Argon2 hash length parameter.",
49-
"default": 32,
50+
"description": "Argon2 hash length.",
51+
"default": argon2.hashLength,
5052
"schema": { "type": "integer", "minimum": 12, "maximum": 64 },
5153
},
5254
},

lib/commands/generate/argon2/verify.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,50 @@ export default class extends Command {
55

66
// static
77
static cli () {
8+
const argon2 = new Argon2();
9+
810
return {
911
"options": {
1012
"id": {
1113
"short": "i",
12-
"description": "Argon2 algorithm to use.",
13-
"default": "argon2id",
14+
"description": "Argon2 algorithm type.",
15+
"default": argon2.id,
1416
"schema": { "enum": [ "argon2d", "argon2i", "argon2id" ] },
1517
},
1618
"argon2-version": {
1719
"short": "v",
1820
"description": "Argon2 algorithm version.",
19-
"default": 19,
21+
"default": argon2.version,
2022
"schema": { "enum": [ 16, 19 ] },
2123
},
2224
"memory-cost": {
2325
"short": "m",
2426
"description": "Argon2 memory cost parameter.",
25-
"default": 65_536,
27+
"default": argon2.memoryCost,
2628
"schema": { "type": "integer", "minimum": 1, "maximum": 2 ** 32 - 1 },
2729
},
2830
"time-cost": {
2931
"short": "t",
3032
"description": "Argon2 time cost parameter.",
31-
"default": 3,
33+
"default": argon2.timeCost,
3234
"schema": { "type": "integer", "minimum": 1, "maximum": 2 ** 32 - 1 },
3335
},
3436
"parallelism": {
3537
"short": "p",
3638
"description": "Argon2 parallelism parameter.",
37-
"default": 4,
39+
"default": argon2.parallelism,
3840
"schema": { "type": "integer", "minimum": 1, "maximum": 255 },
3941
},
4042
"salt-length": {
4143
"short": "s",
42-
"description": "Argon2 salt length parameter.",
43-
"default": 16,
44+
"description": "Argon2 salt length.",
45+
"default": argon2.saltLength,
4446
"schema": { "type": "integer", "minimum": 8, "maximum": 48 },
4547
},
4648
"hash-length": {
4749
"short": "h",
48-
"description": "Argon2 hash length parameter.",
49-
"default": 32,
50+
"description": "Argon2 hash length.",
51+
"default": argon2.hashLength,
5052
"schema": { "type": "integer", "minimum": 12, "maximum": 64 },
5153
},
5254
},

0 commit comments

Comments
 (0)