-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.ts
111 lines (101 loc) · 2.21 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { assertEquals } from "jsr:@std/[email protected]";
import { hash } from "./mod.ts";
const encoder = new TextEncoder();
const encode = (str: string) => encoder.encode(str);
const hex = (arr: ArrayBuffer) =>
new Uint8Array(arr).reduce(
(m, i) => m + ("0" + i.toString(16)).slice(-2),
"",
);
const password = encode("password");
const salt = encode("somesalt");
Deno.test({
name: "Argon2d 0x10",
fn: () => {
assertEquals(
hex(hash(password, salt, {
algorithm: "Argon2d",
version: 0x10,
tCost: 2,
mCost: 65536,
pCost: 1,
})),
"2ec0d925358f5830caf0c1cc8a3ee58b34505759428b859c79b72415f51f9221",
);
},
});
Deno.test({
name: "Argon2d 0x13",
fn: () => {
assertEquals(
hex(hash(password, salt, {
algorithm: "Argon2d",
version: 0x13,
tCost: 2,
mCost: 65536,
pCost: 1,
})),
"955e5d5b163a1b60bba35fc36d0496474fba4f6b59ad53628666f07fb2f93eaf",
);
},
});
Deno.test({
name: "Argon2i 0x10",
fn: () => {
assertEquals(
hex(hash(password, salt, {
algorithm: "Argon2i",
version: 0x10,
tCost: 2,
mCost: 65536,
pCost: 1,
})),
"f6c4db4a54e2a370627aff3db6176b94a2a209a62c8e36152711802f7b30c694",
);
},
});
Deno.test({
name: "Argon2i 0x13",
fn: () => {
assertEquals(
hex(hash(password, salt, {
algorithm: "Argon2i",
version: 0x13,
tCost: 2,
mCost: 65536,
pCost: 1,
})),
"c1628832147d9720c5bd1cfd61367078729f6dfb6f8fea9ff98158e0d7816ed0",
);
},
});
Deno.test({
name: "Argon2id 0x10",
fn: () => {
assertEquals(
hex(hash(password, salt, {
algorithm: "Argon2id",
version: 0x10,
tCost: 2,
mCost: 65536,
pCost: 1,
})),
"980ebd24a4e667f16346f9d4a78b175728783613e0cc6fb17c2ec884b16435df",
);
},
});
Deno.test({
name: "Argon2id 0x13",
fn: () => {
assertEquals(
hex(hash(password, salt, {
algorithm: "Argon2id",
version: 0x13,
tCost: 2,
mCost: 65536,
pCost: 1,
})),
"09316115d5cf24ed5a15a31a3ba326e5cf32edc24702987c02b6566f61913cf7",
);
},
});