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.