1 | var bcrypt = require('../bcrypt');
|
2 |
|
3 | (async () => {
|
4 | const start = Date.now();
|
5 |
|
6 |
|
7 | const salt = await bcrypt.genSalt(10)
|
8 | console.log('salt: ' + salt);
|
9 | console.log('salt cb end: ' + (Date.now() - start) + 'ms');
|
10 |
|
11 |
|
12 | const crypted = await bcrypt.hash('test', salt)
|
13 | console.log('crypted: ' + crypted);
|
14 | console.log('crypted cb end: ' + (Date.now() - start) + 'ms');
|
15 | console.log('rounds used from hash:', bcrypt.getRounds(crypted));
|
16 |
|
17 |
|
18 | const res = await bcrypt.compare('test', crypted)
|
19 | console.log('compared true: ' + res);
|
20 | console.log('compared true cb end: ' + (Date.now() - start) + 'ms');
|
21 |
|
22 |
|
23 | const res = await bcrypt.compare('bacon', crypted)
|
24 | console.log('compared false: ' + res);
|
25 | console.log('compared false cb end: ' + (Date.now() - start) + 'ms');
|
26 |
|
27 | console.log('end: ' + (Date.now() - start) + 'ms');
|
28 | })();
|