Compare commits

...

4 Commits

3 changed files with 26 additions and 3 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.cringe_studios</groupId>
<artifactId>CringeAuthenticatorLibrary</artifactId>
<version>1.4</version>
<version>1.5</version>
<name>CringeAuthenticatorLibrary</name>
<description>The Library of the Cringe Authenticator</description>
<build>

View File

@ -7,11 +7,13 @@ import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public enum OTPAlgorithm{
SHA1("HmacSHA1"),
SHA1 ("HmacSHA1"),
SHA224("HmacSHA224"),
SHA256("HmacSHA256"),
SHA384("HmacSHA384"),
SHA512("HmacSHA512");
SHA512("HmacSHA512"),
MD5 ("HmacMD5");
private String javaName;

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
public void lengthTest() {
assertDoesNotThrow(() -> {