From 87b2558858475eaf64ceff8fae55ee0f503a83a6 Mon Sep 17 00:00:00 2001 From: dlPtr Date: Sat, 10 Sep 2022 18:31:11 +0800 Subject: [PATCH] Update: use existed function --- totp.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/totp.go b/totp.go index b0b0771..7695468 100644 --- a/totp.go +++ b/totp.go @@ -33,9 +33,8 @@ func (t *TOTP) Now() string { // Generate the current time OTP and expiration time func (t *TOTP) NowWithExpiration() (string, int64) { - interval64 := int64(t.interval) - timeCodeInt64 := time.Now().Unix() / interval64 - expirationTime := (timeCodeInt64 + 1) * interval64 + timeCodeInt64 := t.timecode(currentTimestamp()) + expirationTime := (timeCodeInt64 + 1) * int64(t.interval) return t.generateOTP(timeCodeInt64), expirationTime }