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


TypeScript bcrypt-nodejs.genSaltSync函数代码示例

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


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

示例1: init

export function init(sequelize, DataTypes) {
    let fields = {
        id: {
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true
        },
        email: {
            type: DataTypes.STRING
        },
        profile: {
            type: DataTypes.JSON //local, google, facebook
        }
    };

    let options = {
        classMethods: {
            generateHash(password) {
                return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
            },
        },
        instanceMethods: {
            getFullName() {
                return `${this.lastName}, ${this.firstName}`;
            }
        }
    };

    let model = helper.defineModel('user', fields, options, sequelize);

    return model;
}
开发者ID:Blocklevel,项目名称:contoso-express,代码行数:32,代码来源:user.ts

示例2: AddPasswordSync

 AddPasswordSync(password: string): void {
     if (password) {
         let it = this;
         let round = (Math.floor(Math.random() * 10) + 1);
         Log.d("User", "AddPasswordSync", "Generating SaltSync", round);
         let salt = bcript.genSaltSync(round);
         Log.d("User", "AddPasswordSync", "Generating HashSync", salt);
         let hash = bcript.hashSync(password, salt);
         Log.d("User", "AddPasswordSync", "password encrypted", hash);
         it.Password = hash;
     }
 }
开发者ID:pteyssedre,项目名称:lazy-uac,代码行数:12,代码来源:models.ts

示例3: setPasswordFn

        setPassword: function setPasswordFn(password: string) {
            const self: IUserInstance = this;
            if (!password) {
                throw new Error('Password Can\'t Be Null!');
            }

            const salt = bcrypt.genSaltSync();
            const encrypted = bcrypt.hashSync(password, salt);

            self.setDataValue('password', encrypted);

            return self.save();
        },
开发者ID:csgpro,项目名称:csgpro.com,代码行数:13,代码来源:user.model.ts

示例4: function

ConsumerSchema.pre('save', function(next: Function): void {
  let user = this

  if (user.isModified('password')) {
  // generate a salt then run callback
    let salt = bcrypt.genSaltSync(CONFIG.USER_SALT_LENGTH)
    user.password = bcrypt.hashSync(user.password, salt)
    user.updated = UTIL.getTimestamp()
  }
  
  if (user.isNew) {
    user.wasNew = user.isNew
  }

  next()
})
开发者ID:yeegr,项目名称:SingularJS,代码行数:16,代码来源:ConsumerModel.ts

示例5: generateHash

userSchema.methods.generateHash = function generateHash(password: string): string {
    return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
}
开发者ID:jabocop,项目名称:TSExpressBoilerplate,代码行数:3,代码来源:user.ts

示例6: function

 encrypt: function(value: string) {
   var salt = bcrypt.genSaltSync(parseInt(process.env.BCRYPT_SALT));
   return bcrypt.hashSync(value, salt);
 },
开发者ID:musnit,项目名称:super-node-starter,代码行数:4,代码来源:security.ts

示例7: bcryptHash

 public static bcryptHash(data: string): string {
   let salt = bcrypt.genSaltSync(10);
   return bcrypt.hashSync(data, salt);
 }
开发者ID:jcdby,项目名称:SuwonCMIAPIServer,代码行数:4,代码来源:Crypto.ts

示例8: function

userSchema.methods.generateHash = function(password) {
    return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
};
开发者ID:Fahad-AQ,项目名称:SalesmanApp,代码行数:3,代码来源:userModels.ts

示例9: generateHash

	export function generateHash(noHashedString: string) {
		return bcrypt.hashSync(noHashedString, bcrypt.genSaltSync(8));
	}
开发者ID:Event-Starter-Kit,项目名称:website,代码行数:3,代码来源:security.ts


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