-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
78 lines (70 loc) · 2.02 KB
/
Copy pathtest.js
File metadata and controls
78 lines (70 loc) · 2.02 KB
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
import test from 'ava';
import execa from 'execa';
import argon2 from '@phc/argon2';
import scrypt from '@phc/scrypt';
import bcrypt from '@phc/bcrypt';
import pbkdf2 from '@phc/pbkdf2';
test('should hash with argon2', async t => {
const result = await execa('./cli.js', ['hash', 'argon2', 'Hello World']);
const match = await argon2.verify(result.stdout, 'Hello World');
t.true(match);
});
test('should verify with argon2', async t => {
const hash = await argon2.hash('Hello World');
const result = await execa('./cli.js', [
'verify',
'argon2',
hash,
'Hello World'
]);
const match = result.stdout;
t.is(match, 'true');
});
test('should hash with scrypt', async t => {
const result = await execa('./cli.js', ['hash', 'scrypt', 'Hello World']);
const match = await scrypt.verify(result.stdout, 'Hello World');
t.true(match);
});
test('should verify with scrypt', async t => {
const hash = await scrypt.hash('Hello World');
const result = await execa('./cli.js', [
'verify',
'scrypt',
hash,
'Hello World'
]);
const match = result.stdout;
t.is(match, 'true');
});
test('should hash with bcrypt', async t => {
const result = await execa('./cli.js', ['hash', 'bcrypt', 'Hello World']);
const match = await bcrypt.verify(result.stdout, 'Hello World');
t.true(match);
});
test('should verify with bcrypt', async t => {
const hash = await bcrypt.hash('Hello World');
const result = await execa('./cli.js', [
'verify',
'bcrypt',
hash,
'Hello World'
]);
const match = result.stdout;
t.is(match, 'true');
});
test('should hash with pbkdf2', async t => {
const result = await execa('./cli.js', ['hash', 'pbkdf2', 'Hello World']);
const match = await pbkdf2.verify(result.stdout, 'Hello World');
t.true(match);
});
test('should verify with pbkdf2', async t => {
const hash = await pbkdf2.hash('Hello World');
const result = await execa('./cli.js', [
'verify',
'pbkdf2',
hash,
'Hello World'
]);
const match = result.stdout;
t.is(match, 'true');
});