本文整理汇总了TypeScript中bcrypt-nodejs.genSalt函数的典型用法代码示例。如果您正苦于以下问题:TypeScript genSalt函数的具体用法?TypeScript genSalt怎么用?TypeScript genSalt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了genSalt函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('Testing genSalt', function(done) {
theSalt = bcrypt.genSalt(10, (err, salt) => {
theSalt = salt;
expect(err).to.equal(null);
done();
});
});
开发者ID:GeekAthelon,项目名称:SoiWidgets,代码行数:7,代码来源:bcrypt-nodejs-mocha.ts
示例2: function
PlatformSchema.pre('save', function(next: Function): void {
let user = this
// generate a salt then run callback
if (user.isNew) {
bcrypt
.genSalt(10, (err: Error, salt: string) => {
if (err) { return next(err) }
// encrypt password with salt
bcrypt.hash(user.password, salt, null, (err, hash) => {
if (err) { return next(err) }
// overwrite plain text password with encrypted password
user.password = hash
next()
})
})
} else {
UTIL.setUpdateTime(user, ['username', 'password', 'nickname', 'name', 'gender', 'mobile', 'email', 'pid', 'avatar', 'background', 'locale', 'city', 'country'])
user.wasNew = user.isNew
next()
}
})
开发者ID:yeegr,项目名称:SingularJS,代码行数:26,代码来源:PlatformModel.ts
示例3: reject
return new Promise<string>((resolve, reject) => {
bcrypt.genSalt(-1, (err, salt) => {
/* istanbul ignore if */
if (err) {
reject(err);
}
resolve(salt);
});
});
开发者ID:GeekAthelon,项目名称:SoiWidgets,代码行数:9,代码来源:password-hash-bcrypt.ts
示例4: save
userSchema.pre("save", function save(next) {
const user = this;
if (!user.isModified("password")) { return next(); }
bcrypt.genSalt(10, (err, salt) => {
if (err) { return next(err); }
bcrypt.hash(user.password, salt, undefined, (err: mongoose.Error, hash) => {
if (err) { return next(err); }
user.password = hash;
next();
});
});
});
开发者ID:omnajjar,项目名称:node-express-app-starter,代码行数:12,代码来源:User.ts
示例5: function
userSchema.pre("save", function(done) {
var user = this;
if (!user.isModified("password")) {
return done();
}
bcrypt.genSalt(SALT_FACTOR, function(err, salt) {
if (err) { return done(err); }
bcrypt.hash(user.password, salt, noop, function(err, hashedPassword) {
if (err) { return done(err); }
user.password = hashedPassword;
done();
});
});
});
开发者ID:Muhammmad-Zubaid,项目名称:learn-typed-express,代码行数:16,代码来源:user.ts
示例6: getPasswordHash
function getPasswordHash(password: string): Promise<string> {
var resolve, reject;
var promise = new Promise<string>((res, rej) => {
resolve = res;
reject = rej;
});
var createHash = (saltError, salt) => {
if (saltError) return reject("Failed to create salt: " + saltError);
bcrypt.hash(password, salt, null, (err, hash) => {
if (err) return reject("Failed to create hash: " + err);
resolve(hash);
});
}
var salt = bcrypt.genSalt(10, createHash);
return promise;
}
开发者ID:Seikho,项目名称:auth-api,代码行数:18,代码来源:createHash.ts
示例7: function
_schema.pre('save', function(next) {
let account: IAccount = this;
if (!account.isModified()) {
return next();
}
if (account.password === '') {
if (!account.activationToken) {
console.log('no password no activationToken');
return next();
}
}
bcrypt.genSalt(1000, (err, salt) => {
if (err) {
return next(err);
}
bcrypt.hash(account.password, salt, ()=>{} ,(err, hash) => {
if (err) {
return next(err);
}
account.password = hash;
next();
})
})
})
开发者ID:DavidOnGitHub,项目名称:questionApp_backend,代码行数:24,代码来源:Account.ts
示例8: AddPassword
AddPassword(password: string, callback: () => void): void {
if (!password) {
throw new Error("password doesn't contain value");
}
let it = this;
let round = (Math.floor(Math.random() * 10) + 1);
Log.d("User", "AddPassword", "Generating Salt", round);
bcript.genSalt(round, (error: Error, salt: string): void => {
if (error) {
Log.c("User", "AddPassword", "bcript.genSalt", error);
throw error;
}
Log.d("User", "Generating Hash", salt);
bcript.hash(password, salt, DataModel.User.encryptingProgress, (error: Error, hash: string): void => {
if (error) {
Log.c("User", "AddPassword", "bcript.hash", error);
throw error;
}
Log.d("User", "AddPassword", "password encrypted", hash);
it.Password = hash;
callback();
});
});
}
开发者ID:pteyssedre,项目名称:lazy-uac,代码行数:24,代码来源:models.ts
示例9: Promise
return new Promise(function(resolve, reject) {
bcrypt.genSalt(rounds, function(err, salt) {
if (err) return reject(err);
return resolve(salt);
});
});
开发者ID:girishgupta211,项目名称:LAAS_Server,代码行数:6,代码来源:bcrypt_thunk.ts
注:本文中的bcrypt-nodejs.genSalt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论