diff --git a/src/main/java/com/amdelamar/jotp/OTP.java b/src/main/java/com/amdelamar/jotp/OTP.java index 2d709b3..2bbd059 100644 --- a/src/main/java/com/amdelamar/jotp/OTP.java +++ b/src/main/java/com/amdelamar/jotp/OTP.java @@ -9,6 +9,7 @@ import com.amdelamar.jotp.type.HOTP; import com.amdelamar.jotp.type.TOTP; import com.amdelamar.jotp.type.Type; +import org.apache.commons.codec.binary.Hex; /** * OTP (One Time Password) utility in Java. To enable two-factor authentication (2FA) using @@ -82,7 +83,7 @@ public static String timeInHex(long timeInMillis) throws IOException { byte[] longBytes = ByteBuffer.allocate(Long.SIZE / Byte.SIZE) .putLong(time) .array(); - return org.apache.commons.codec.binary.Hex.encodeHexString(longBytes); + return new String(Hex.encodeHex(longBytes)); } /** @@ -112,7 +113,7 @@ public static String create(String secret, String base, int digits, Type type) // convert Base32 secret to Hex byte[] bytes = new org.apache.commons.codec.binary.Base32().decode(secret); - String key = org.apache.commons.codec.binary.Hex.encodeHexString(bytes); + String key = new String(Hex.encodeHex(bytes)); if (type == Type.HOTP) { HOTP hotp = new HOTP(); @@ -161,7 +162,7 @@ public static boolean verify(String secret, String base, String code, int digits // convert Base32 secret to Hex byte[] bytes = new org.apache.commons.codec.binary.Base32().decode(secret); - String key = org.apache.commons.codec.binary.Hex.encodeHexString(bytes); + String key = new String(Hex.encodeHex(bytes)); // generate code to compare String ncode = null;