-
Notifications
You must be signed in to change notification settings - Fork 0
/
bun.index.js
43 lines (37 loc) · 1.12 KB
/
bun.index.js
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
import bcryptjs from 'bcryptjs';
import { password, argon2idConfig } from './password.js';
import { bench, group, run } from 'mitata';
const argonConfig = Object.assign(
{
algorithm: 'argon2id',
},
argon2idConfig
);
const hashedBunArgon = await Bun.password.hash(password, argonConfig);
console.info('Bun Argon2id:', hashedBunArgon);
const hashedBunBcrypt = await Bun.password.hash(password, {
algorithm: 'bcrypt',
});
console.info('Bun Bcrypt:', hashedBunBcrypt);
const hashedBcryptjs = await bcryptjs.hash(password, 10);
console.info('Bcryptjs:', hashedBcryptjs);
console.info();
group('Bun.sh', () => {
bench('Bun Argon2id', async () => {
const hashed = await Bun.password.hash(password, argonConfig);
await Bun.password.verify(password, hashed);
});
bench('Bun Bcrypt', async () => {
const hashed = await Bun.password.hash(password, {
algorithm: 'bcrypt',
});
await Bun.password.verify(password, hashed);
});
bench('Bcryptjs', async () => {
const hashed = await bcryptjs.hash(password, 10);
await bcryptjs.compare(password, hashed);
});
});
await run({
colors: false,
});