diff --git a/gototp.go b/gototp.go index 1d770c2..d07ea48 100644 --- a/gototp.go +++ b/gototp.go @@ -56,7 +56,7 @@ func (totp *TOTP) Now() int32 { // will be valid in the next period (FromNow(1)). // This means that every code is therefore valid for 3 * totp.Period. func (totp *TOTP) FromNow(periods int64) int32 { - period := (time.Now().Unix() / int64(totp.Period)) + int64(periods) + period := math.Floor(time.Now().Unix() / int64(totp.Period)) + int64(periods) return totp.ForPeriod(period) }