Roonia.TOTP
1.0.1
dotnet add package Roonia.TOTP --version 1.0.1
NuGet\Install-Package Roonia.TOTP -Version 1.0.1
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="Roonia.TOTP" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Roonia.TOTP --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Roonia.TOTP, 1.0.1"
#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 Roonia.TOTP as a Cake Addin #addin nuget:?package=Roonia.TOTP&version=1.0.1 // Install Roonia.TOTP as a Cake Tool #tool nuget:?package=Roonia.TOTP&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TOTP SetupCode and Verification helper
This is a library for .NET to generate SetupCode
for TOTP Authenticator apps like Google Authenticator
and to verify the codes Authenticator app will generate.
How to use
Using this library is very straight forward. Just install package Roonia.TOTP
to your project and start using TOTPAuthenticator
class. It has methods to generate SetupCode
for users of your applications. The process of adding an authenticator app as a two-factor authentication method for your application :
- Generate an unique secret key for each user
- Get
SetupCode
based on generated secret key for each user - Call
ValidatePIN
method for checking the totp code users enter every time they want to login (Or any other action).
Generate SetupCode
using Roonia.TOTP;
//just for sample, you can use anther strategy for generating secret keys of your application
var secretKey = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
var totp = new TOTPAuthenticator();
var userAccountName = "imun22@gmail.com";
var appName = "myapp";
var setupCode = totp.GetStupCode(userAccountName, appName, secretKey);
Validating PINs
//You have to save secret key for each user, somewhere
var secretKey = ""; //read from database
//assume that this variable hold the user input
var totp = new TOTPAuthenticator();
var userTotpCode = "...";
if(totp.ValidatePIN(secretKey, userTotpCode, TimeSpan.FromMinutes(1))) {
//continue the login (or any other) process.
}
else {
//Raise exception or show error to user.
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.