Google Authenticator TOTP和常规TOTP有什么区别

时间:2020-08-03 01:32:21

标签: one-time-password google-authenticator

Google身份验证器应用会生成令牌,我们尝试通过以下方式使用OTP库(otplib)进行复制。即使同时运行,一个匹配但另一个不匹配

import { authenticator, totp, hotp } from 'otplib'

const secret = "NZQKPMNENSPOWUQZ"

console.log(authenticator.generate(secret)) // matches the app token
console.log(totp.generate(secret)) // does not match

为什么两个生​​成的令牌不同?每个生成器的选项之间的区别是编码,因此也尝试了相同的结果

totp.options = {encoding: 'hex'} // default is 'ascii'

如何使用totp(或hotp)生成与authenticator相同的代码

0 个答案:

没有答案
相关问题