async_compare.js 857 B

123456789101112131415161718192021
  1. var bcrypt = require('../bcrypt');
  2. var start = Date.now();
  3. bcrypt.genSalt(10, function(err, salt) {
  4. console.log('salt: ' + salt);
  5. console.log('salt cb end: ' + (Date.now() - start) + 'ms');
  6. bcrypt.hash('test', salt, function(err, crypted) {
  7. console.log('crypted: ' + crypted);
  8. console.log('crypted cb end: ' + (Date.now() - start) + 'ms');
  9. console.log('rounds used from hash:', bcrypt.getRounds(crypted));
  10. bcrypt.compare('test', crypted, function(err, res) {
  11. console.log('compared true: ' + res);
  12. console.log('compared true cb end: ' + (Date.now() - start) + 'ms');
  13. });
  14. bcrypt.compare('bacon', crypted, function(err, res) {
  15. console.log('compared false: ' + res);
  16. console.log('compared false cb end: ' + (Date.now() - start) + 'ms');
  17. });
  18. });
  19. })
  20. console.log('end: ' + (Date.now() - start) + 'ms');