From 4aaee91b617de26aff7841fc1459205dc70708d6 Mon Sep 17 00:00:00 2001 From: Eugene Fox Date: Mon, 31 May 2021 01:39:13 +0300 Subject: [PATCH] Created OTPService.ValidateCode (markdown) --- OTPService.ValidateCode.md | 93 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 OTPService.ValidateCode.md diff --git a/OTPService.ValidateCode.md b/OTPService.ValidateCode.md new file mode 100644 index 0000000..99f0de3 --- /dev/null +++ b/OTPService.ValidateCode.md @@ -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. \ No newline at end of file