-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #894 from lpizzinidev/patch-1
- Loading branch information
Showing
1 changed file
with
23 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
var bcrypt = require('../bcrypt'); | ||
|
||
var start = Date.now(); | ||
bcrypt.genSalt(10, function(err, salt) { | ||
console.log('salt: ' + salt); | ||
console.log('salt cb end: ' + (Date.now() - start) + 'ms'); | ||
bcrypt.hash('test', salt, function(err, crypted) { | ||
(async () => { | ||
const start = Date.now(); | ||
|
||
// genSalt | ||
const salt = await bcrypt.genSalt(10) | ||
console.log('salt: ' + salt); | ||
console.log('salt cb end: ' + (Date.now() - start) + 'ms'); | ||
|
||
// hash | ||
const crypted = await bcrypt.hash('test', salt) | ||
console.log('crypted: ' + crypted); | ||
console.log('crypted cb end: ' + (Date.now() - start) + 'ms'); | ||
console.log('rounds used from hash:', bcrypt.getRounds(crypted)); | ||
bcrypt.compare('test', crypted, function(err, res) { | ||
console.log('compared true: ' + res); | ||
console.log('compared true cb end: ' + (Date.now() - start) + 'ms'); | ||
}); | ||
bcrypt.compare('bacon', crypted, function(err, res) { | ||
console.log('compared false: ' + res); | ||
console.log('compared false cb end: ' + (Date.now() - start) + 'ms'); | ||
}); | ||
}); | ||
}) | ||
console.log('end: ' + (Date.now() - start) + 'ms'); | ||
|
||
// compare | ||
const res = await bcrypt.compare('test', crypted) | ||
console.log('compared true: ' + res); | ||
console.log('compared true cb end: ' + (Date.now() - start) + 'ms'); | ||
|
||
// compare | ||
const res = await bcrypt.compare('bacon', crypted) | ||
console.log('compared false: ' + res); | ||
console.log('compared false cb end: ' + (Date.now() - start) + 'ms'); | ||
|
||
console.log('end: ' + (Date.now() - start) + 'ms'); | ||
})(); |