dotnet add package Utilities.VerificationCode
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 Utilities.VerificationCode.Services;
public class MyProcess
{
public string Generate()
{
var verificationCodeService = new VerificationCodeService();
return verificationCodeService.Generate();
}
}
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
}
}
using Utilities.VerificationCode.Interfaces;
public class MyProcess
{
private readonly IVerificationCodeService _verificationCodeService;
public MyProcess(IVerificationCodeService verificationCodeService) =>
_vaultService = vaultService;
public string Generate() =>
_verificationCodeService.Generate();
}