I tried to copy the HOTPAlgorithm.java codes (HOTPAlgorithm.java) and compared it against the official HOTP RFC 4226's sample implementation (RFC4226 Page 27) found on Page 27 of the official RFC4226 document. Both the HOTPAlgorithm.java and the implementation in the RFC4226 are written by the same author whom is Loren Hart and set to version 1.0. Both codes are the same essnetially from my comparison.
I tried to run test vector for 6 digit HOTP codes (without modifying the HOTPAlgorithm.java script) and noticed that the source codes given in the RFC4226 and the HOTPAlgorithm.java produces different test vector results against the published RFC4226 results with exactly the same setting.
Is there a discrepancy in the Java codes published by RFC4226 sample Java codes and the HOTPAlogrithm.java when compared against the RFC4226 test vectors ?
Test Results from HOTPAlgorithm.java and RFC4226 Java codes (both produce the same results):
int otp = binary % DIGITS_POWER[codeDigits];
int otp = (int) (binary % Math.pow(10, codeDigits));
int otp = binary % 1000000;