xlzd / gotp

Golang OTP(One-Time Password) Library.
MIT License
468 stars 67 forks source link

Provide a method for checking if secret is valid to avoid panic checking #18

Closed djherbis closed 2 years ago

djherbis commented 2 years ago

Calls time Now() and At() can panic if the secret is invalid, but there's no safe way using this library to check if the secret is valid without handling the panic.

Providing a non-panic method for checking this would be ideal (IsValid() or something which could return the err from byteSecret() instead of panicing).

Most APIs should not panic and should just push errors up the stack instead.

mergenchik commented 2 years ago

good point @djherbis, if anybody has time to implement it and send PR, I will review this.

mergenchik commented 2 years ago

Closing this issue, implemented in #24