mirror of
https://github.com/XFox111/SimpleOTP.git
synced 2026-04-22 08:00:45 +03:00
Created OTPService.ValidateCode (markdown)
@@ -0,0 +1,93 @@
|
||||
> ## Note of deprecation
|
||||
> Methods described in this article are deprecated and will be removed from future releases starting version 2.0. Please, use [OTPService.ValidateHotp](https://github.com/XFox111/SimpleOTP/wiki/OTPService.ValidateHotp) and [OTPService.ValidateTotp](https://github.com/XFox111/SimpleOTP/wiki/OTPService.ValidateTotp) instead
|
||||
|
||||
Namespace: `SimpleOTP`
|
||||
|
||||
Assembly: `SimpleOTP.dll`
|
||||
|
||||
## Overloads
|
||||
| Overload | Description |
|
||||
| --- | --- |
|
||||
| [ValidateCode(int, ref OTPConfiguration, int, bool)](#ValidateCodeint-ref-OTPConfiguration-int-bool) | Generates a new OTP code with provided configuration. |
|
||||
| [ValidateCode(int, OTPConfiguration, TimeSpan)](#ValidateCodeint-OTPConfiguration-TimeSpan) | Generates a new TOTP code with provided configuration and for specific interval. |
|
||||
|
||||
## ValidateCode(int, ref OTPConfiguration, int, bool)
|
||||
> ## Note of deprecation
|
||||
> Methods described in this article are deprecated and will be removed from future releases starting version 2.0. Please, use [OTPService.ValidateHotp](https://github.com/XFox111/SimpleOTP/wiki/OTPService.ValidateHotp) and [OTPService.ValidateTotp](https://github.com/XFox111/SimpleOTP/wiki/OTPService.ValidateTotp) instead
|
||||
|
||||
Validates provided HOTP code with provided parameters.
|
||||
```csharp
|
||||
[Obsolete("Use ValidateHotp() instead.")]
|
||||
public static bool ValidateCode(int otp, ref OTPConfiguration target, int toleranceSpan, bool resyncCounter);
|
||||
```
|
||||
### Parameters
|
||||
`otp` `Int32`
|
||||
|
||||
HOTP code to validate.
|
||||
|
||||
`target` [OTPConfiguration](https://github.com/XFox111/SimpleOTP/wiki/OTPConfiguration)
|
||||
|
||||
OTP configuration for check codes generation.
|
||||
|
||||
`toleranceSpan` `Int32`
|
||||
|
||||
Counter span from which OTP codes remain valid.
|
||||
|
||||
`resyncCounter` `Boolean`
|
||||
|
||||
Defines whether method should resync `OTPConfiguration.Counter` of the `target` or not after successful validation.
|
||||
### 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.TOTP`
|
||||
|
||||
[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 HOTP codes.
|
||||
|
||||
---
|
||||
|
||||
## ValidateCode(int, OTPConfiguration, TimeSpan)
|
||||
> ## Note of deprecation
|
||||
> Methods described in this article are deprecated and will be removed from future releases starting version 2.0. Please, use [OTPService.ValidateHotp](https://github.com/XFox111/SimpleOTP/wiki/OTPService.ValidateHotp) and [OTPService.ValidateTotp](https://github.com/XFox111/SimpleOTP/wiki/OTPService.ValidateTotp) instead
|
||||
|
||||
Validates provided TOTP code with provided parameters.
|
||||
```csharp
|
||||
[Obsolete("Use ValidateTotp() instead.")]
|
||||
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