wstrange / GoogleAuth

Google Authenticator Server side code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request

hwacookie opened this issue · comments

I might be missing out on something here, but ... would it be possible to make the calculateCode() method public?
I'm using your lib on the server side, and for testing purposes, it would be great if I could use the same lib for the client side code as well. Others might be interested to use your code when writing client applications.

I worked around it by shamelessly borrowing from your code and basically copying the checkCode() method. I just changed the return type from "boolean" to "String[]", so it now returns an array of the calculated hashes instead of a "isValid".

The signature of my method now looks like this:

/**
 * Creates a set of One Time Passwords for the given secret.
 *
 * @param aSecret the secret for which OTPs shall be generated
 * @param aNumberOfOTPs the number of OTPs to be generated. The one "in the middle" is the "most current one". 
 * @return an array of OTPs.
 */
public static String[] createOTP(String aSecret, int aNumberOfOTPs) {
      ...
    }

And, in any case: Thanks for putting this together!

Yeah! The description mentions that we can use this library as a client, but clearly we can't!

Shouldn't getTotpPassword();
give you the OTP ? And that is public. Or am i missing something in the OTP implementation?