Added MD5 tests

This commit is contained in:
TheArrayser 2023-07-17 15:32:01 +02:00
parent 985a58c407
commit 9791cfb0f8

View File

@ -52,6 +52,27 @@ public class OTPTest {
} }
} }
@Test
public void md5Test() {
String secret = String.format("%x", new BigInteger(1, "MD5".getBytes()));
String base32secret = Base32.encode(hexStr2Bytes(secret));
//System.out.println("MD5 String: " + base32secret);
assertDoesNotThrow(() -> {
OTP testOTP1 = OTPType.HOTP.instance(base32secret, OTPAlgorithm.MD5, 6, 0, 30, false);
for(int i = 0; i < 5; i++) {
String calculatedPin = testOTP1.getPin();
testOTP1.incrementCounter();
if(VERBOSE) {
System.out.println("Calculated MD5 pin - counter: " + i + " pin: " + calculatedPin);
}
}
});
}
@Test @Test
public void lengthTest() { public void lengthTest() {
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {