https://github.com/ed555009/utilities-verificationcode
A nuget package for generating 2~8 digits verification code targeting NetStandard2.0
https://github.com/ed555009/utilities-verificationcode
2factor c-sharp dotnet6 mfa security verification-code
Last synced: 6 months ago
JSON representation
A nuget package for generating 2~8 digits verification code targeting NetStandard2.0
- Host: GitHub
- URL: https://github.com/ed555009/utilities-verificationcode
- Owner: ed555009
- License: mit
- Created: 2024-05-05T03:36:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-05T06:27:44.000Z (over 1 year ago)
- Last Synced: 2025-06-03T00:04:19.271Z (8 months ago)
- Topics: 2factor, c-sharp, dotnet6, mfa, security, verification-code
- Language: C#
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Utilities.VerificationCode
[](LICENSE)

[](https://www.nuget.org/packages/Utilities.VerificationCode)





## Installation
```bash
dotnet add package Utilities.VerificationCode
```
## Add services(optional)
You can add the service to the DI container.
```csharp
using Utilities.VerificationCode.Interfaces;
using Utilities.VerificationCode.Services;
ConfigureServices(IServiceCollection services)
{
// this injects as SINGLETON
services.AddSingleton();
}
```
## Using service
### Simple usage
```csharp
using Utilities.VerificationCode.Services;
public class MyProcess
{
public string Generate()
{
var verificationCodeService = new VerificationCodeService();
return verificationCodeService.Generate();
}
}
```
### Generate code with specific length
You can generate 2~8 digits code by specifying the length. (default is 6)
```csharp
using Utilities.VerificationCode.Services;
public class MyProcess
{
public string Generate()
{
var verificationCodeService = new VerificationCodeService();
return verificationCodeService.Generate(4); // generate 4 digits code
}
}
```
### Use dependency injection
```csharp
using Utilities.VerificationCode.Interfaces;
public class MyProcess
{
private readonly IVerificationCodeService _verificationCodeService;
public MyProcess(IVerificationCodeService verificationCodeService) =>
_vaultService = vaultService;
public string Generate() =>
_verificationCodeService.Generate();
}
```