1
0
mirror of https://github.com/XFox111/SimpleOTP.git synced 2026-04-23 08:08:40 +03:00

Created OTPService.GenerateCode (markdown)

2021-05-31 01:08:05 +03:00
parent 234b7b9022
commit 31d6a0d00e
+59
@@ -0,0 +1,59 @@
Namespace: `SimpleOTP`
Assembly: `SimpleOTP.dll`
## Overloads
| Overload | Description |
| --- | --- |
| [GenerateCode(ref OTPConfiguration)](#GenerateCoderef-OTPConfiguration) | Generates a new OTP code with provided configuration. |
| [GenerateCode(ref OTPConfiguration, DateTime)](#GenerateCoderef-OTPConfiguration-DateTime) | Generates a new TOTP code with provided configuration and for specific interval. |
## GenerateCode(ref OTPConfiguration)
Generates a new OTP code with provided configuration.
```csharp
public static OTPCode GenerateCode(ref OTPConfiguration target);
```
### Parameters
`target` [OTPConfiguration](https://github.com/XFox111/SimpleOTP/wiki/OTPConfiguration)
OTP configuration object.
### Exceptions
[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
If you're using HOTP algorithm, save `target` after calling the function.
If OTP algorithm is HOTP, `target` counter is increased by 1.
---
## GenerateCode(ref OTPConfiguration, DateTime)
Generates a new OTP code with provided configuration.
```csharp
public static OTPCode GenerateCode(ref OTPConfiguration target, DateTime date);
```
### Parameters
`target` [OTPConfiguration](https://github.com/XFox111/SimpleOTP/wiki/OTPConfiguration)
OTP configuration object.
`date` [DateTime](https://docs.microsoft.com/en-us/dotnet/api/system.datetime?view=net-5.0)
`DateTime` for which the OTP should be generated.
### Returns
[OTPCode](https://github.com/XFox111/SimpleOTP/wiki/OTPCode) instance with generated code.
### Exceptions
[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
If you're using HOTP algorithm, save `target` after calling the function.
If you're using HOTP algorithm, `date` will be ignored.
If OTP algorithm is HOTP, `target` counter is increased by 1.