How to use the bcrypt-nodejs.genSalt function in bcrypt-nodejs

To help you get started, we’ve selected a few bcrypt-nodejs 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 maxvyaznikov / imapseagull / app_tests.js View on Github external
function createUser(err) {
                    if (err) throw err;
                    bcrypt.genSalt(10, function(err, salt) {
                        if (err) throw err;
                        bcrypt.hash(app_tests.testuser_pass, salt, function() {}, function(err, hash) {
                            if (err) throw new Error(err);

                            app_tests.db_users.insert({ // add test user
                                email: app_tests.testuser_email,
                                password: hash
                            }, function(err, user) {
                                app_tests.testuser = user;
                                console.log('[DB: testuser added]');

                                this(err);
                            }.bind(this));
                        }.bind(this));
                    }.bind(this));
                },
github usehenri / henri / packages / user / index.js View on Github external
return new Promise((resolve, reject) => {
    if (typeof password !== 'string') {
      return reject(new Error('you must provide a string to encrypt'));
    }
    if (password.length < 6) {
      return reject(new Error('minimum password string is 6 characters'));
    }
    if (henri.isTest) {
      rounds = 10;
    }
    bcrypt.genSalt(rounds, (err, salt) => {
      if (err) {
        return reject(err);
      }

      bcrypt.hash(password, salt, null, (err, hash) => {
        if (err) {
          return reject(err);
        }
        return resolve(hash);
      });
    });
  });
}
github DigitalFlow / Open-Certification-Trainer / src / controllers / UserController.ts View on Github external
const hashPassword = (password: string, callBack: (error: Error, hash: string) => void) => {
  bcrypt.genSalt(10, (err, salt) => {
    if (err) {
      return callBack(err, undefined);
    }
    bcrypt.hash(password, salt, undefined, (err: Error, hash) => {
      if (err) {
        return callBack(err, undefined);
      }

      callBack(undefined, hash);
    });
  });
};
github zuhrasofyan / sails-passport / api / models / User.js View on Github external
beforeCreate: function (user, cb) {
    delete user.password_confirmation;
    bcrypt.genSalt(10, function (err, salt) {
        bcrypt.hash(user.password, salt, function () {
        }, function (err, hash) {
            user.password = hash;
            cb(null, user);
        });
    });
  }
};
github eddywashere / node-stripe-membership-saas / server / models / user.js View on Github external
userSchema.pre('save', function(next) {
  var user = this;

  if (!user.isModified('password')) return next();

  bcrypt.genSalt(10, function(err, salt) {
    if (err) return next(err);

    bcrypt.hash(user.password, salt, null, function(err, hash) {
      if (err) return next(err);
      user.password = hash;
      next();
    });
  });
});

bcrypt-nodejs

A native JS bcrypt library for NodeJS.

Unknown
Latest version published 12 years ago

Package Health Score

39 / 100
Full package analysis