Closed vigorouscoding closed 3 years ago
This is superceded by https://github.com/j256/two-factor-auth/pull/23. I made some changes to your code but took the functionality. Changed the length argument to be int not Integer. Also fixed a problem with the zero prefix which would have caused issues if the generated number was less than 8 digits. Thanks again @vigorouscoding !
… digits) but kept 6 as the default (as per the standard)
As the Google Authenticator allows the use of 8 digits for the OTPs (see https://github.com/google/google-authenticator/wiki/Key-Uri-Format), I thought it might make a nice addition to your code. I tried to keep the source code style in line with yours and also added a few tests.
Basically I just added a default setting
DEFAULT_OTP_LENGTH = 6
which is used if no length is given in order to ensure that functionality does not change if it your library is used somewhere. Alternatively users would now be able to use the new parameterlength
in all the functions to request a OTP with a different length. I did not add checks that only 6 or 8 digits are allowed, however.I hope this meets your standards and you will accept the PR :)