TOTP for 2FA is incredibly easy to implement. So what’s your excuse?
Time-based one-time passwords are one of the more secure approaches to 2FA
— certainly much better than SMS. And it’s much easier to implement than
SMS as well. The algorithm is as follows:
- Divide the current Unix timestamp by 30
- Encode it as a 64-bit big endian integer
- Write the encoded bytes to a SHA-1 HMAC initialized with the TOTP shared key
- Let offs = hmac