Skip to content

A nuget package for generating 2~8 digits verification code targeting NetStandard2.0

License

Notifications You must be signed in to change notification settings

ed555009/utilities-verificationcode

Repository files navigation

Utilities.VerificationCode

GitHub Build Status Nuget

Coverage Quality Gate Status Reliability Rating Security Rating Vulnerabilities

Installation

dotnet add package Utilities.VerificationCode

Add services(optional)

You can add the service to the DI container.

using Utilities.VerificationCode.Interfaces;
using Utilities.VerificationCode.Services;

ConfigureServices(IServiceCollection services)
{
	// this injects as SINGLETON
	services.AddSingleton<IVerificationCodeService, VerificationCodeService>();
}

Using service

Simple usage

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)

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

using Utilities.VerificationCode.Interfaces;

public class MyProcess
{
	private readonly IVerificationCodeService _verificationCodeService;

	public MyProcess(IVerificationCodeService verificationCodeService) =>
		_vaultService = vaultService;

	public string Generate() =>
		_verificationCodeService.Generate();
}

About

A nuget package for generating 2~8 digits verification code targeting NetStandard2.0

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages