How to use the bcryptjs.hashSync function in bcryptjs

To help you get started, we’ve selected a few bcryptjs 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 liangfengbo / nodejs-koa-blog / app / models / admin.js View on Github external
set(val) {
      // 加密
      const salt = bcrypt.genSaltSync(10);
      // 生成加密密码
      const psw = bcrypt.hashSync(val, salt);
      this.setDataValue("password", psw);
    },
    allowNull: false,
github Human-Connection / Human-Connection / backend / src / middleware / passwordMiddleware.js View on Github external
CreateUser: async (resolve, root, args, context, info) => {
      args.password = await bcrypt.hashSync(args.password, 10)
      const result = await resolve(root, args, context, info)
      result.password = '*****'
      return result
    }
  },
github letterpad / letterpad / src / api / seed / seed.js View on Github external
export async function insertAuthor(models) {
  return models.Author.bulkCreate([
    {
      fname: "John",
      lname: "Dave",
      email: "demo@demo.com",
      password: bcrypt.hashSync("demo", 12),
      social: JSON.stringify({
        twitter: "https://twitter.com",
        facebook: "https://facebook.com",
        github: "https://github.com",
        instagram: "https://instagram.com",
      }),
      roleId: 1,
      bio:
        "Provident quis sed perferendis sed. Sed quo nam eum. Est quos beatae magnam ipsa ut cupiditate nostrum officiis. Vel hic sit voluptatem. Minus minima quis omnis.",
      avatar: "/admin/images/avatar.png",
    },
    {
      fname: "Jim",
      lname: "Parker",
      email: "author@letterpad.app",
      password: bcrypt.hashSync("demo", 12),
github dunizb / CodeTest / island / app / models / user.js View on Github external
set(val) {
            const salt = bcryptjs.genSaltSync(10)
            const safePwd = bcryptjs.hashSync(val, salt)
            this.setDataValue('password', safePwd)
        }
    },
github jinwyp / AngularJS-Learning-Demo / core / models / user / user.js View on Github external
var encryptPassword = function (password) {
     var salt = bcrypt.genSaltSync(10);
     return bcrypt.hashSync(password, salt);
 };
github dwyl / hapi-typescript-example / src / users / user.ts View on Github external
function hashPassword(password: string): string {
  if (!password) {
    return null;
  }

  return Bcrypt.hashSync(password, Bcrypt.genSaltSync(8));
}
github vidar-team / hctf_final_platform / src / controllers / TeamController.ts View on Github external
this.redisClient.incr("teams:count", (incrError, teamId) => {
                    const token = crypto.randomBytes(20).toString("hex");
                    this.redisClient.hmset(`team:${teamId}`, {
                        name: request.body.name,
                        password: bcrypt.hashSync(request.body.password),
                        token,
                    }, () => {
                        this.redisClient.hset("name.team.mapping", request.body.name, teamId.toString(), () => {
                            this.redisClient.hset("token.teamname.mapping", token, request.body.name, () => {
                                return response.json({
                                    status: "ok",
                                });
                            });
                        });
                    });
                });
            }
github Seolhun / vue-type-graphql-example / server / src / app / utils / PasswordEncoderUtils.ts View on Github external
static bcryptedPasswordSync(password: string): string {
    const salt = bcrypt.genSaltSync(10);
    return bcrypt.hashSync(password, salt);
  }
github stipsan / epic / src / server / database / user.js View on Github external
.then(userId =>
      redis.multi([
        ['hsetnx', 'emails', userData.email, userId],
        ['hsetnx', `user:${userId}`, 'id', userId],
        ['hsetnx', `user:${userId}`, 'username', userData.username],
        ['hsetnx', `user:${userId}`, 'email', userData.email],
        ['hsetnx', `user:${userId}`, 'password', bcrypt.hashSync(userData.password, 10)]
      ]).exec()
    )
github rithinch / event-driven-microservices-docker-example / services / authentication / src / controllers / auth.controller.js View on Github external
add: async (message) => {
    let user;
    try {
      user = JSON.parse(message.content.toString());
      const hashedPassword = bcrypt.hashSync(user.password, 8);
      await Auth.create({
        role: user.role,
        emailAddress: user.emailAddress,
        password: hashedPassword,
      });
      logger.info(`user auth record created - ${user.emailAddress}`);
    } catch (err) {
      logger.error(`Error creating auth record for user ${user.emailAddress} : ${err}`);
    }
  },
};

bcryptjs

Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.

MIT
Latest version published 8 years ago

Package Health Score

70 / 100
Full package analysis