Search code examples
javascripttotp

How to check if entered TOTP secret key format is correct?


I'm doing a small web project to generate OTP online (like Google authenticator). I'm currently using otpauth library to generate OTP code. It can't generate code if secret key is wrong. So how do I check if entered secret key is correct?


Solution

  • it is nothing more than a base32 string, and there are many libraries that can check that. example: How to check if a string is base32 encoded in javascript