Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with leading 0's #4

Closed
rgautam98 opened this issue Jul 31, 2018 · 2 comments
Closed

Issue with leading 0's #4

rgautam98 opened this issue Jul 31, 2018 · 2 comments

Comments

@rgautam98
Copy link

I have small question. Because the return type is int, the leading 0's are being dropped. This is being an issue for in the long run as the otp that is being shown is only 5 digits.

Now, can the return type be an String so that the user does not worry about the leading 0's. Personally, we had to waste a lot of time only to come to this conculsion.

@jchambers
Copy link
Owner

java-otp deliberately avoids making any decisions about the presentation of one-time passwords. This is, in large part, to allow callers to support locales that don't use Arabic numerals (0-9). One consequence is that callers will need to format numbers to account for leading zeroes.

We can consider expanding documentation, FAQs, and examples, but I don't think returning one-time passwords as Strings is the right way to go.

@Flo354
Copy link

Flo354 commented Nov 6, 2019

Hi there,

I completely understand your point on returning an integer. It makes sense.
But why don't adding just an helper function generateOneTimePasswordString which would be embedded in the class and do the conversion, for the ones that want to use it?

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants