DotNetBrightener.TimeBasedOtp
2024.0.14.6-preview-1901001
This is a prerelease version of DotNetBrightener.TimeBasedOtp.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DotNetBrightener.TimeBasedOtp --version 2024.0.14.6-preview-1901001
NuGet\Install-Package DotNetBrightener.TimeBasedOtp -Version 2024.0.14.6-preview-1901001
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="2024.0.14.6-preview-1901001" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetBrightener.TimeBasedOtp --version 2024.0.14.6-preview-1901001
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DotNetBrightener.TimeBasedOtp, 2024.0.14.6-preview-1901001"
#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=2024.0.14.6-preview-1901001&prerelease // Install DotNetBrightener.TimeBasedOtp as a Cake Tool #tool nuget:?package=DotNetBrightener.TimeBasedOtp&version=2024.0.14.6-preview-1901001&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 | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- System.Runtime.Caching (>= 8.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.