本文整理汇总了TypeScript中bcrypt-nodejs.hash函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hash函数的具体用法?TypeScript hash怎么用?TypeScript hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hash函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('Testing hash generation', function(done) {
bcrypt.hash(thePassword, theSalt, null, (err, hash) => {
theHash = hash;
expect(err).to.equal(null);
done();
});
});
示例2: resolve
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);
});
}
示例3: 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();
});
});
示例4: function
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();
});
});
示例5: reject
return new Promise<string>((resolve, reject) => {
bcrypt.hash(password, salt, null, (err, hash) => {
/* istanbul ignore if */
if (err) {
reject(err);
}
resolve(hash);
});
});
示例6: 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();
})
})
示例7: next
.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()
})
})
示例8: callback
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();
});
});
示例9: Promise
return new Promise(function(resolve, reject) {
bcrypt.hash(data, salt, null, function(err, hash) {
if (err) return reject(err);
return resolve(hash);
});
});
示例10: Promise
return new Promise((resolve, reject) => {
bcrypt.hash(pass, null, null, (err, hash) => {
if (err) reject(err);
else resolve(hash);
});
})