• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript crypto.pbkdf2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: function

userSchema.methods.hashPassword = function(password, cb) {
  this.salt = crypto.randomBytes(16).toString('hex');
  crypto.pbkdf2(password, this.salt, 1000, 32, function(err, buff) {
    if (err) return cb(err);
    cb(null, buff.toString('hex'));
  });
}
开发者ID:Jeremy-Doucet,项目名称:DanExample,代码行数:7,代码来源:user.model.ts


示例2: function

adminSchema.method("comparePassword", function(password: string, done: Function){
  crypto.pbkdf2(password, this.salt, 1000, 32, (err,hash) => {
    if(err) return done (err);
    done(null, hash == this.password)
  });

});
开发者ID:benstelzer,项目名称:admissioncalculator,代码行数:7,代码来源:admin.model.ts


示例3: function

userSchema.methods.hashPassword = function(password: string, done: Function){
  this.salt = crypto.randomBytes(16).toString('hex');
  crypto.pbkdf2(password, this.salt, 1000, 32, (err, hash) => {
    if(err) return done(err);
    done(null, hash.toString('hex'));
  })
}
开发者ID:andrewwb,项目名称:JeremysTraining,代码行数:7,代码来源:userModel.ts


示例4: function

userSchema.method('hashPassword', function(password: string, done: Function) {
  this.salt = crypto.randomBytes(16).toString('hex');
  crypto.pbkdf2(new Buffer(password), this.salt, 1000, 32, "sha512", (err, hash) => {
    if (err) return done(err);
    this.password = hash.toString('hex');
    done();
  });
});
开发者ID:UtopianOwl,项目名称:dcproj,代码行数:8,代码来源:user.model.ts


示例5: reject

    return new Promise<Buffer>( (resolve, reject ) => {

      crypto.pbkdf2( password, salt, ITERATIONS, keylen, 'sha256', (err, key) => {

        if ( err )
          reject( err );
        else
          resolve( key );
      } );
    })
开发者ID:cryptographix,项目名称:labs-workshop-secure-web-applications,代码行数:10,代码来源:user-auth.ts


示例6: Error

loginRouter.post("/signup", (request: Request, response: Response, next: NextFunction) => {
    if (!request.body.hasOwnProperty("password")) {
        const err = new Error("No password");
        return next(err);
    }

    const salt = randomBytes(128).toString("base64");

    pbkdf2(request.body.password, salt, 10000, length, digest, (err: Error, hash: Buffer) => {
        response.json({
            hashed: hash.toString("hex"),
            salt,
        });
    });
});
开发者ID:venki143mca,项目名称:TeamBirthday,代码行数:15,代码来源:login.ts


示例7: function

loginRouter.post('/signup', function (request: Request, response: Response, next: NextFunction) {
    if (!request.body.hasOwnProperty('password')) {
        let err = new Error('No password');
        return next(err);
    }

    const salt = randomBytes(128).toString('base64');

    pbkdf2(request.body.password, salt, 10000, length, digest, (err: Error, hash: Buffer) => {
        response.json({
            hashed: hash.toString('hex'),
            salt: salt
        });
    });
});
开发者ID:akazimirov,项目名称:domic,代码行数:15,代码来源:login.ts


示例8: function

loginRouter.post("/signup", function (req: Request, res: Response, next) {
    if (!req.body.hasOwnProperty("password")) {
        let err = new Error("No password");
        return next(err);
    }

    const salt = randomBytes(128).toString("base64");

    pbkdf2(req.body.password, salt, 10000, length, function (err, hash) {
        res.json({
            hashed: hash.toString("hex"),
            salt: salt
        });
    });
});
开发者ID:BLamy,项目名称:angular2-express-starter,代码行数:15,代码来源:login.ts


示例9: function

	crypto.pbkdf2(oldpassword, response.locals.user.login.salt, response.locals.user.login.iterations, 32, function(err: Error, hashedPasswordBuffer: Buffer) {
		var hashedPassword: string = hashedPasswordBuffer.toString("hex");
		if (hashedPassword !== response.locals.user.login.hash) {
			response.locals.passwordFail = true;
			response.locals.passwordMessage = "Old password is not correct"
		}
		if (response.locals.passwordFail) {
			// Render fail page
			response.render("passwordchange", function(err: Error, html: string): void {
				if (err) {
					console.error(err);
					response.send(500, "A Jade error occurred!");
					return;
				}
				response.send(html);
			});
			return;
		}
		// Valid password change request
		var newSalt: string = crypto.randomBytes(32).toString("hex");
		crypto.pbkdf2(password1, newSalt, response.locals.user.login.iterations, 32, function(err: Error, hashedPasswordBuffer: Buffer) {
			var hashedPassword: string = hashedPasswordBuffer.toString("hex");
			// Update in DB
			Collections.Users.update({"username": response.locals.user.username}, {$set: {"login.salt": newSalt, "login.hash": hashedPassword}}, {w:1}, function(err: Error) {
				if (err) {
					response.locals.passwordFail = true;
					response.locals.passwordMessage = "A database error occurred";
					console.error(err);
				}
				else {
					response.locals.passwordSuccess = "success";
					response.locals.passwordMessage = "Password changed successfully";
				}
				response.render("passwordchange", function(err: Error, html: string): void {
					if (err) {
						console.error(err);
						response.send(500, "A Jade error occurred!");
						return;
					}
					response.send(html);
				});
				return;
			});
		});
	});
开发者ID:petschekr,项目名称:Dragonoids-Website,代码行数:45,代码来源:server.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript crypto.pbkdf2Sync函数代码示例发布时间:2022-05-24
下一篇:
TypeScript crypto.createVerify函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap