How to use the bcrypt.encrypt function in bcrypt

To help you get started, we’ve selected a few bcrypt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robashton / HoverBattles / src / server / data.js View on Github external
self.createUser = function(username, password, email, callback) {
     bcrypt.encrypt(password, salt, function(err, hash){
     db.save({
        type:"user",
        username: username,
        password: hash,
        email: email
      },
      callback);
    });
  };
github powmedia / mongoose-plugins / lib / authenticator.js View on Github external
bcrypt.gen_salt(workFactor, function(err, salt) {
            if (err) callback(err);
            
            bcrypt.encrypt(password, salt, function(err, hashedPassword) {
                if (err) callback(err);
                
                callback(null, hashedPassword);
            });
        });
    }
github tdryer / express-forum / app.js View on Github external
bcrypt.gen_salt(12, function (err, salt) {
        bcrypt.encrypt(form.data.password, salt, function (err, hash) {
          db.run('INSERT INTO user (username, password_hash) values (?, ?)', 
                 form.data.username, hash, function (err) {
            req.flash('info', 'Account created. Login to continue.');
            res.redirect('/login');
          });
        });
      });
    },
github kevbook / Base-Node.js-App / lib / authx.js View on Github external
bcrypt.gen_salt(10, function(err, salt) {
    bcrypt.encrypt(password, salt, function(err, hash) {
      if (err) {
        callback(new Error('Failed to encrypt password.'));
      }
      else {
        user.password = hash;
        callback(null, user);
      }
    });
  });
};