我应该如何增加代词的有效时间在说话容易库。
var secret =speakEasy.generateSecret({length:20});
var token = speakEasy.totp({
secret: secret.base32,
encoding: 'base32',
step:100
});默认情况下,它在验证为false之后的几秒钟内有效。
var verified=speakEasy.totp.verify({
secret:secret,
encoding:'base32',
token:token
});您可以查看下面的链接
http://speakeasyjs.github.io/speakeasy/docs/speakeasy/2.0.0/global.html https://github.com/speakeasyjs/speakeasy
发布于 2016-04-25 10:11:25
根据您提供的文档链接,step是使用time和epoch在一段时间后使令牌失效的属性。
var secret = speakEasy.generateSecret({length:20});
var token = speakEasy.totp({
secret : secret.base32,
encoding : 'base32',
// time : Date.new(), default is current time.
// epoch : 0, default is 0. It is the offset from UNIX epoch.
// step is used, with time as time + step, to invalidate the token.
step : 100
});

因此,如果epoch和time设置为默认值,则可以使用step来定义令牌的有效时间(以秒为单位)。你用了step : 100。这就是为什么,您的令牌在100秒后无效。因此,如果增加step的时间,则可以提高令牌的有效性。
注:时间以秒为单位。
希望这能有所帮助。或者查询评论。
https://stackoverflow.com/questions/36796507
复制相似问题