From 314570471ffbc2fdc888bd92fe9bd44dc882b185 Mon Sep 17 00:00:00 2001 From: tushar Date: Fri, 3 Feb 2023 10:38:42 +0530 Subject: [PATCH] Function for custom steps using custom seconds argument --- src/main/java/de/taimos/totp/TOTP.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/de/taimos/totp/TOTP.java b/src/main/java/de/taimos/totp/TOTP.java index 21505f9..50a8437 100644 --- a/src/main/java/de/taimos/totp/TOTP.java +++ b/src/main/java/de/taimos/totp/TOTP.java @@ -44,6 +44,12 @@ private static long getStep() { return System.currentTimeMillis() / 30000; } + private static String getOTPBySeconds(final int sec, final String key) { + int milliSec = sec * 1000; + long steps = System.currentTimeMillis() / milliSec; + return getOTP( step, key); + } + private static String getOTP(final long step, final String key) { String steps = Long.toHexString(step).toUpperCase(); while (steps.length() < 16) {