How to use bcrypt-nodejs - 10 common examples

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 iiimosley / GoodQuotes / api / config / passport-strat.js View on Github external
const isValidPassword = (userpass, password) => {
      console.log('isValidPassword', userpass, password);

      // hashes the passed-in password and then compares it to the hashed password fetched from the db
      return bCrypt.compareSync(password, userpass);
    };
github worknenjoy / gitpay / models / user.js View on Github external
generateHash: (password) => {
        /* eslint-disable no-sync */
        return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null)
      }
    },
github iiimosley / GoodQuotes / api / config / passport.js View on Github external
const isValidPassword = (userpass, password) => {
      // hashes the passed-in password and then compares it to the hashed password fetched from the db
      return bCrypt.compareSync(password, userpass);
    };
github punchcard-cms / punchcard / lib / init / passport.js View on Github external
.then(user => {
    if ((user.length < 1) || (!bcrypt.compareSync(password, user[0].password))) {
      return cb(null, false, { message: config.authentication.messages.login.error });
    }

    // register user's role for access
    acl.addUserRoles(user[0].id.toString(), user[0].role);

    return cb(null, user[0].id);
  })
  .catch(err => {
github JKHeadley / rest-hapi / api / utilities / password-helper.js View on Github external
var hash_password = function(plaintext) {
    var salt = bcrypt.genSaltSync(10);
    var hash = bcrypt.hashSync(plaintext, salt);
    return hash;
};
github saggiyogesh / nodeportal / lib / PasswordUtil.js View on Github external
exports.encryptSync = function(password){
    var algo = AppProperties.get("PASSWORD_ENC_ALGO");
    if (algo == BCRYPT) {
        var bcrypt = require('bcrypt-nodejs');
        var salt = bcrypt.genSaltSync(10);
        return bcrypt.hashSync(password, salt);
    }
    else {
        return getSHA1Hash(password);
    }
};
github gustavohenrique / gh1 / server / nodejs / src / models / User.js View on Github external
function hashPassword (instance) {
        var salt = bcrypt.genSaltSync(10);
        var hash = bcrypt.hashSync(instance.password, salt);
        instance.password = hash;
    }
github mgm-interns / team-radio / server / src / entities / user / User.ts View on Github external
public generateToken() {
    const secret = `${this.username}${this.email}${Date.now()}`;
    const token = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(4));
    const refreshToken = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(2));
    this.authToken = new AuthToken(token, refreshToken);
  }
github mgm-interns / team-radio / server / src / entities / user / User.ts View on Github external
public generateToken() {
    const secret = `${this.username}${this.email}${Date.now()}`;
    const token = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(4));
    const refreshToken = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(2));
    this.authToken = new AuthToken(token, refreshToken);
  }

bcrypt-nodejs

A native JS bcrypt library for NodeJS.

Unknown
Latest version published 11 years ago

Package Health Score

39 / 100
Full package analysis