Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 2.17 KB

README_english.md

File metadata and controls

19 lines (15 loc) · 2.17 KB

Target

The target of this project was create a One-time password generator when the user clicks on the "generate password" button, a combination of numbers will immediately appear along with a counter. When the time reaches zero the password will expire and it will be necessary to generate another code.


About the project

A one-time password (OTP) is a sequence of numbers and/or characters that is generated and sent to the user to be used in a single login attempt or transaction, for this reason the password is also called "one-time" password.


Relevant explanations about the code

  • The random function is used to generate the random OTP which is predefined in the Math library;
  • The Math.floor function return the floor of any floating number to an integer value;
  • Math.random() is a function that returns any random number between 0 and 1.
  • Learn more about the above functions in the documentation: Math.random(), Math.floor().

  • Within the loop of repetition with for I determined that the index will be 0, and what is the maximum number of digits that will be supplied to compose the password; In question, I opted for a 6 digit password;
  • Also that, with setTimeout()andsetInterval() I created a function so that, every 10 minutes the page is reloaded, forcing the user to need to generate a new code. Which reads as if the OTP code has expired.

  • Learn more about the functions used and mentioned above in the MDN documentation: SetTimeout(), setInterval().