DotNetBrightener.TimeBasedOtp
2025.0.2-preview-277
This is a prerelease version of DotNetBrightener.TimeBasedOtp.
dotnet add package DotNetBrightener.TimeBasedOtp --version 2025.0.2-preview-277
NuGet\Install-Package DotNetBrightener.TimeBasedOtp -Version 2025.0.2-preview-277
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetBrightener.TimeBasedOtp" Version="2025.0.2-preview-277" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetBrightener.TimeBasedOtp --version 2025.0.2-preview-277
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DotNetBrightener.TimeBasedOtp, 2025.0.2-preview-277"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DotNetBrightener.TimeBasedOtp as a Cake Addin #addin nuget:?package=DotNetBrightener.TimeBasedOtp&version=2025.0.2-preview-277&prerelease // Install DotNetBrightener.TimeBasedOtp as a Cake Tool #tool nuget:?package=DotNetBrightener.TimeBasedOtp&version=2025.0.2-preview-277&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Time Based OTP Library
© 2022 DotNet Brightener.
Installation
Run this in command line:
dotnet add package DotNetBrightener.TimeBasedOtp
Or add the following to .csproj
file
<PackageReference Include="DotNetBrightener.TimeBasedOtp" Version="2022.10.0" />
You should check the latest version from Nuget Site
Usage
Register service
serviceCollection.AddOtpProvider();
In your service / controller:
// inject the service
IOTPProvider otpProvider;
// generate a secret
var secret = "<some random string>";
// define the length of the password to generate
var passwordLength = 6;
// indicates whether the secret's spaces matter or not.
var ignoreSpaces = false; // false: Spaces matter. true: Spaces don't matter
var otp = otpProvider.GetPassword(secret, passwordLength, ignoreSpaces);
// the adjacent intervals to check for the OTP. The greater this value is, the higher risk of being hijacked.
var checkAdjacentIntervals = 2;
var isOtpValid = otpProvider.ValidateOTP(otp, secret, ignoreSpaces, checkAdjacentIntervals;
Note
The secret should be stored securely within your application.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- System.Runtime.Caching (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.