Closed itsabdelrahman closed 4 years ago
@yeojz And thanks a bunch for your time and effort working on this outstanding library! 👏
hi @ar-maged
Thanks.
Looked at the code. The reason why it is not matching is because you are using totp instead of the authenticator methods. The difference between the two is that the keys used in authenticator are base32 encoded.
i.e. if you want to use totpToken, then you'll have to decode first secret -> base32decode(secret) -> totpToken
Modification:
import { keyDecoder } from '@otplib/plugin-base32-enc-dec';
// assumes the original secret to be already encoded.
const totp = totpToken(
keyDecoder(secret, 'hex'),
totpOptions({
createDigest,
encoding: 'hex'
})
);
alternatively, you can use the authenticatorToken method provided by the library.
Outstanding! Thank you very much for the thorough explanation 👌
Describe the bug Getting incorrect TOTPs when using
@otplib/core
&@otplib/plugin-crypto-js
with Expo.To Reproduce Steps to reproduce the behavior:
yarn
yarn web
oryarn ios
oryarn android
Expected behavior Getting correct TOTPs in accordance with https://otplib.yeojz.dev or https://rootprojects.org/authenticator using the same secret.
Screenshots![Screen Shot 2020-03-08 at 02 01 56](https://user-images.githubusercontent.com/11808903/76154699-dfafc280-60e0-11ea-99ef-faa53f9cb785.png)
Details
v12.0.1
v10.15.3
v1.22.1