How to generate OTP Number with 6 digits

Android Developer picture Android Developer · Jun 20, 2015 · Viewed 70.1k times · Source

What is an OTP number in a login authentication system? Is there any specific algorithm for generating OTP numbers using java (android). Or is an OTP something like random number? How can this be achieved, with optimization.

Answer

cornelinux picture cornelinux · Sep 9, 2015

Please do not reinvent the wheel - especially in case of security and cryptography. You might end up in a really bad state.

Use algorithms, that the community agreed upon like the HOTP and TOTP algorithm specified by the Open Authentication Iniative. These algorithms are also used by the google authenticater and specified in these RFCs. Read them. They are simple.

http://tools.ietf.org/html/rfc4226

https://tools.ietf.org/html/rfc6238