本文整理汇总了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);
}
});
}
});
示例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);
});
});
示例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);
});
});
});
示例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();
});
});
示例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) {}
}
示例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);
});
});
示例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);
}
});
});
示例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();
});
});
示例9: Promise
return new Promise((resolve, reject) => {
bcrypt.hash(password, salt, (err, result) => {
if (err) {
return reject(err);
}
resolve(result);
});
});
示例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);
});
});
示例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))
);
})
示例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;
}
示例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()
}
})
})
示例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,
}
},
示例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();
});
});