DotNetBrightener.TimeBasedOtp 2026.0.2

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package DotNetBrightener.TimeBasedOtp --version 2026.0.2
                    
NuGet\Install-Package DotNetBrightener.TimeBasedOtp -Version 2026.0.2
                    
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="2026.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetBrightener.TimeBasedOtp" Version="2026.0.2" />
                    
Directory.Packages.props
<PackageReference Include="DotNetBrightener.TimeBasedOtp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetBrightener.TimeBasedOtp --version 2026.0.2
                    
#r "nuget: DotNetBrightener.TimeBasedOtp, 2026.0.2"
                    
#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.
#:package DotNetBrightener.TimeBasedOtp@2026.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetBrightener.TimeBasedOtp&version=2026.0.2
                    
Install as a Cake Addin
#tool nuget:?package=DotNetBrightener.TimeBasedOtp&version=2026.0.2
                    
Install as a Cake Tool

Time Based OTP Library

Copyright © 2017 - 2026 Vampire Coder (formerly DotnetBrightener)

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 Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DotNetBrightener.TimeBasedOtp:

Package Downloads
DotNetBrightener.NotificationService

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.0.3-preview-772 31 4/3/2026
2026.0.3-preview-770 61 4/2/2026
2026.0.3-preview-769 67 4/2/2026
2026.0.2 74 4/2/2026
2026.0.2-preview-v2026-0-1-755 119 3/27/2026
2026.0.2-preview-759 89 4/1/2026
2026.0.2-preview-758 110 3/29/2026
2026.0.2-preview-757 107 3/29/2026
2026.0.2-preview-756 113 3/27/2026
2026.0.2-preview-754 100 3/27/2026
2026.0.1 107 3/27/2026
2026.0.1-preview-752 107 3/26/2026
2026.0.1-preview-750 108 3/26/2026
2026.0.1-preview-749 109 3/25/2026
2026.0.1-preview-748 106 3/23/2026
2026.0.1-preview-742 108 3/22/2026
2026.0.1-preview-741 118 3/16/2026
2025.0.11-preview-771 48 4/2/2026
2025.0.11-preview-768 55 4/2/2026
2025.0.11-preview-762 58 4/2/2026
Loading failed