当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript bcrypt.hash函数代码示例

本文整理汇总了TypeScript中bcrypt.hash函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hash函数的具体用法?TypeScript hash怎么用?TypeScript hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了hash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                bcrypt.hash(password, 8, function(err, hash) {
                    if(!err) {
                        var request = new Request(
                            '[dbo].[CreateNewUser]',
                            function(err, rowCount) {
                                console.log('RC: ' + rowCount)
                                if (err) {
                                    console.log(err);
                                    res.status(500).send();
                                }
                                else {
                                    connection.close();
                                    res.status(200).send();
                                }
                            }
                        )

                        request.addParameter('UserId', TYPES.NVarChar, username);
                        request.addParameter('Password', TYPES.NVarChar, hash);
                        request.addParameter('Depot', TYPES.NVarChar, depot);
                        request.addParameter('CreatedOn', TYPES.DateTime, new Date());
                        request.addParameter('ApiKey', TYPES.NVarChar, Guid.raw());
                        request.addParameter('ServerKey', TYPES.NVarChar, Guid.raw());
                        request.addParameter('CreateUsers', TYPES.Bit, createUsers)

                        connection.callProcedure(request);
                    }
                });
            }
        });
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:35,代码来源:createUser.ts

示例2: done

 bcrypt.genSalt(10, (err, salt) => {
     if (err) return done (err);
     bcrypt.hash(password, salt, (err, hash) => {
         if (err) return done (err);
         done(null, hash);
     });
 });
开发者ID:aurbina83,项目名称:veteranconnect,代码行数:7,代码来源:model.ts

示例3: User

 User.findOne({ username }, (err, user: IUser) => {
   if (user != null) return res.sendStatus(409);
   bcrypt.hash(req.body.password, 10, (err, password) => {
     new User({ username, password, attributes }).save((err, user: IUser) => {
       res.json(user);
     });
   });
 });
开发者ID:rcchen,项目名称:famjam,代码行数:8,代码来源:api.ts

示例4: function

 bcrypt.genSalt(config.saltFactor, function (err, salt) {
     if (err) return next(err);
     bcrypt.hash(user.password, salt, function (err, hash) {
         if (err) return next(err);
         user.password = hash;
         next();
     });
 });
开发者ID:mortonprod,项目名称:CleaningWebsite,代码行数:8,代码来源:dbStore.ts

示例5: hashPassword

 async hashPassword(password: string) {
   const saltRounds = 10;
   const salt = await bcrypt.genSalt(saltRounds);
   try {
     const hashedPassword = await bcrypt.hash(password, salt);
     this.password = hashedPassword;
   } catch(err) {}
 }
开发者ID:HackrLabs,项目名称:HakrPass,代码行数:8,代码来源:user.ts

示例6: resolve

      bcrypt.genSalt(saltLength, (err, salt) => {

        if (err) return reject(err);
        bcrypt.hash(text, salt, (error, hash) => {

          if (error) return reject(error);
          return resolve(hash);
        });
      });
开发者ID:chen-framework,项目名称:chen,代码行数:9,代码来源:crypto.ts

示例7: function

 return new Promise<string>( (resolve: any, reject: any) => {
     bcrypt.hash(data, this._rounds, function (err, hash) {
         if (err) {
             return reject(err);
         } else {
             return resolve(hash);
         }
     });
 });
开发者ID:Uter1007,项目名称:sumobase.core,代码行数:9,代码来源:password.service.ts

示例8: next

    bcrypt.genSalt(cf.SALT_WORKER_VALUE, (err, salt) => {
        if (err) return next(err);

        bcrypt.hash(user.password, salt, (err, hash) => {
            if (err) return next(err);
            user.password = hash;
            next();
        });
    });
开发者ID:tinganho,项目名称:api.codemanager.com,代码行数:9,代码来源:user.ts

示例9: Promise

 return new Promise((resolve, reject) => {
     bcrypt.hash(password, salt, (err, result) => {
         if (err) {
             return reject(err);
         }
         
         resolve(result);
     });
 });
开发者ID:kamilbiela,项目名称:auth360-backend,代码行数:9,代码来源:BCryptPasswordHasher.ts

示例10: done

 bcrypt.genSalt(SALT_ROUNDS, (saltErr, salt) => {
   /* istanbul ignore next */
   if (saltErr) return done(saltErr);
   bcrypt.hash(password, salt, (hashErr, hash) => {
     /* istanbul ignore next */
     if (hashErr) return done(hashErr);
     done(null, hash);
   });
 });
开发者ID:Jeremy-Doucet,项目名称:Blog-Example-Typescript,代码行数:9,代码来源:user.model.ts

示例11: genSalt

 genSalt(10, function (err, salt) {
     if (err) { return next(err); }
     hash(req.body['passwd'], salt, (err, hashed) => (err) ? next(err)
         :
         db().none("INSERT INTO stakeholder(username, passwd, email, register_time, avatar) VALUES ($1, $2, $3, $4, $5)",
             [ req.body['username'], hashed, req.body['email'], new Date(), config['blog']['default_avatar'] ])
         .then(() => res.redirect('/user/login'),
             (reason) => next(reason))
     );
 })
开发者ID:secondwtq,项目名称:expressus,代码行数:10,代码来源:user.ts

示例12: passwordConvert

    public static async passwordConvert(password: string): Promise<string> {
        let returnPassword = '';

        try {
            returnPassword = await hash(password, 10);
        } catch (error) {
            console.error(error);
        };

        return returnPassword;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:11,代码来源:admins.ts

示例13: function

 bcrypt.genSalt(10, function(err, salt){
         bcrypt.hash(user.password, salt, function(err, hash){
                 if(err){
                         console.log(err)
                         cb(err)
                 } else {
                         user.password = hash
                         cb()
                 }
         })
 })
开发者ID:nyamteam,项目名称:rest-server,代码行数:11,代码来源:User.ts

示例14: async

 signup: async (parent, { name, email, password }, context) => {
   const hashedPassword = await hash(password, 10)
   const user = await context.prisma.createUser({
     name,
     email,
     password: hashedPassword,
   })
   return {
     token: sign({ userId: user.id }, APP_SECRET),
     user,
   }
 },
开发者ID:markthink,项目名称:prisma-examples,代码行数:12,代码来源:Mutation.ts

示例15: next

 bcrypt.genSalt(SALT_WORK_FACTOR, (err, salt) => {
     if (err) return next(err); 
 
     // hash the password using our new salt
     bcrypt.hash(user.password, salt, (err, hash) => {
         if (err) return next(err);
 
         // override the cleartext password with the hashed one
         user.password = hash;
         next();
     });
 });
开发者ID:krishnavteja,项目名称:node-auth,代码行数:12,代码来源:user.ts


注:本文中的bcrypt.hash函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。