akanass / rx-otp

HMAC-based (HOTP) and Time-based (TOTP) One-Time Password manager. Works with Google Authenticator for Two-Factor Authentication.
MIT License
76 stars 9 forks source link

TOTP generator creates wrong code #28

Open mpirli opened 1 month ago

mpirli commented 1 month ago

I'm trying to use this library to generate a TOTP code. However the code is always different from the one given in my authenticator app. I've tried all the different algorithms and nothing. I wonder if it's something in the timestamp, as I am at UTC + 3, but I don't know how to fix it. I've tried passing as a parameter timestamp: Date.now() and timestamp: Date.now() - 1000 60 60 * 3, but nothing works.

akanass commented 1 month ago

Please have a look at the tests written in the library to validate all the OTP and maybe you will find the answer. I use it personally and all is working for me with Google Authenticator