Closed edent closed 5 months ago
This is because the interval division is subject to a rounding error for inputs smaller than the interval: https://github.com/pyauth/pyotp/blob/249674bf2814e1fcc3152c618514159cd44b4610/src/pyotp/totp.py#L113-L116
So it seems that values in the range [1-interval, -1] "work". (For the default interval of 30, this is from -29 up to -1).
Running
totp.at(-29)
produces a TOTP code. Runningtotp.at(-30)
correctly raises "ValueError("input must be positive integer")" as per: https://github.com/pyauth/pyotp/blob/249674bf2814e1fcc3152c618514159cd44b4610/src/pyotp/otp.py#L28-L34I'm just curious as to why some negative numbers work.