mirror of
https://github.com/XFox111/SimpleOTP.git
synced 2026-04-22 08:00:45 +03:00
Created OTPService.ValidateTotp (markdown)
@@ -0,0 +1,36 @@
|
|||||||
|
Namespace: `SimpleOTP`
|
||||||
|
|
||||||
|
Assembly: `SimpleOTP.dll`
|
||||||
|
|
||||||
|
Validates provided TOTP code with provided parameters.
|
||||||
|
```csharp
|
||||||
|
public static bool ValidateTotp(int otp, OTPConfiguration target, TimeSpan? toleranceTime = null);
|
||||||
|
```
|
||||||
|
### Parameters
|
||||||
|
`otp` `Int32`
|
||||||
|
|
||||||
|
OTP code to validate.
|
||||||
|
|
||||||
|
`target` [OTPConfiguration](https://github.com/XFox111/SimpleOTP/wiki/OTPConfiguration)
|
||||||
|
|
||||||
|
OTP configuration for check codes generation.
|
||||||
|
|
||||||
|
`toleranceTime` [TimeSpan?](https://docs.microsoft.com/en-us/dotnet/api/system.timespan?view=net-5.0)
|
||||||
|
|
||||||
|
Time span from which OTP codes remain valid. Default: 15 seconds.
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
`True` if code is valid, `False` if it isn't.
|
||||||
|
|
||||||
|
### Exceptions
|
||||||
|
[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.ArgumentException?view=net-5.0)
|
||||||
|
|
||||||
|
`target.Type` is `OTPType.HOTP`
|
||||||
|
|
||||||
|
[NullReferenceException](https://docs.microsoft.com/en-us/dotnet/api/system.nullreferenceexception?view=net-5.0)
|
||||||
|
|
||||||
|
`target` is `null`
|
||||||
|
### Examples
|
||||||
|
See `OTPService` usage examples on [Code generation/validation](https://github.com/XFox111/SimpleOTP/wiki/Code-generation-or-validation)
|
||||||
|
### Remarks
|
||||||
|
Use this method only with Time-based OTP codes.
|
||||||
Reference in New Issue
Block a user