Skip to content

Commit af5b541

Browse files
committed
Use binary representation of salt instead of string when calling argon2-browser, to fix hex or base64 encoded salt values
1 parent 2a1294f commit af5b541

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/core/operations/Argon2.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Argon2 extends Operation {
7979
"Argon2id": argon2.ArgonType.Argon2id
8080
};
8181

82-
const salt = Utils.convertToByteString(args[0].string || "", args[0].option),
82+
const salt = Utils.convertToByteArray(args[0].string || "", args[0].option),
8383
time = args[1],
8484
mem = args[2],
8585
parallelism = args[3],

tests/operations/tests/Hash.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,25 @@ TestRegister.addTests([
11461146
}
11471147
]
11481148
},
1149+
{
1150+
name: "Argon2: Base64 Salt",
1151+
input: "argon2password",
1152+
expectedOutput: "$argon2i$v=19$m=4096,t=3,p=1$c29tZXNhbHQ$s43my9eBljQADuF/LWCG8vGqwAJzOorKQ0Yog8jFvbw",
1153+
recipeConfig: [
1154+
{
1155+
op: "Argon2",
1156+
args: [
1157+
{"option": "Base64", "string": "c29tZXNhbHQ="},
1158+
3,
1159+
4096,
1160+
1,
1161+
32,
1162+
"Argon2i",
1163+
"Encoded hash"
1164+
]
1165+
}
1166+
]
1167+
},
11491168
{
11501169
name: "Argon2 compare",
11511170
input: "argon2password",

0 commit comments

Comments
 (0)