I have a 2FA code in my nodeJS server application that utilizes speakeasy module to verify whether the passed key is valid or not. I am using google Authenticator app on the client side. I am using a secret key = "A0B0C0D0E0F0A1B1C1D1E1F2". This works on Android devices well . However, when I try the same on an Iphone, I face the following issues:
secretKey = "A0B0C0D0E0F0A1B1C1D1E1F2";
var verified = speakeasy.totp.verify({
secret: secretKey,
encoding: 'base32',
token: userToken
});
if(!verified) {
// verification failed
} else {
// verification ok
}
How do I fix this issue so that it works on both Android and Iphone devices?
Note: The app is still in test region. The secret keys in prod will be stored on a permanent storage/db.
Thanks.
The secret used in totp.verify was in lowercase. When i converted that to upper case, it started working fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.