Made code workable for old Java Versions
This commit is contained in:
parent
291ecd6c7a
commit
806726d109
@ -3,7 +3,6 @@ package com.cringe_studios.cringe_authenticator_library.impl;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
|
||||
import com.cringe_studios.cringe_authenticator_library.OTPAlgorithm;
|
||||
import com.cringe_studios.cringe_authenticator_library.OTPException;
|
||||
@ -27,7 +26,7 @@ public class TOTP extends HOTP {
|
||||
@Override
|
||||
public String getPin() throws OTPException{
|
||||
try {
|
||||
return getPinAt(Instant.now().getEpochSecond());
|
||||
return getPinAt(System.currentTimeMillis() / 1000);
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new OTPException("Your secret is invalid! Please rescan the code!", e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
@ -37,7 +36,7 @@ public class TOTP extends HOTP {
|
||||
|
||||
@Override
|
||||
public long getCounter() {
|
||||
return getCounterAt(Instant.now().getEpochSecond() - super.getTimeCorrection());
|
||||
return getCounterAt(System.currentTimeMillis() / 1000 - super.getTimeCorrection());
|
||||
}
|
||||
|
||||
private long getCounterAt(long unixSecond) {
|
||||
|
Loading…
Reference in New Issue
Block a user