CGLibs.2FA 8.51.128

dotnet add package CGLibs.2FA --version 8.51.128                
NuGet\Install-Package CGLibs.2FA -Version 8.51.128                
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="CGLibs.2FA" Version="8.51.128" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CGLibs.2FA --version 8.51.128                
#r "nuget: CGLibs.2FA, 8.51.128"                
#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 CGLibs.2FA as a Cake Addin
#addin nuget:?package=CGLibs.2FA&version=8.51.128

// Install CGLibs.2FA as a Cake Tool
#tool nuget:?package=CGLibs.2FA&version=8.51.128                

cglibs-2fa

OTP, HOTP and TOTP library for .NET. Create and validate 6-8 digit codes.

Usage

Create a new instance of the Authenticator class and create a qr code image for the user to scan.

CGLibs._2FA.Imaging.Authenticator auth = new CGLibs._2FA.Imaging.Authenticator();
auth.Width = 500;
auth.Height = 500;
auth.Period = 60;

pictureBox1.Image = auth.GetQRCodeImage("$ecretKeyForTestingPurposesThatIsReallyLongAndCrazyToTryAndUse", 
	"Issuer", "UserAccount@SomeDomainOrAppEtc");

Generate a code

TOTPGenerator totpGenerator = new CGLibs._2FA.TOTP.TOTPGenerator("SecretKey");
string code = totpGenerator.GenerateForDate();

Validate a code

string usercode = "123456";
TOTPValidator totpValidator = new CGLibs._2FA.TOTP.TOTPValidator("SecretKey");
bool isValid = totpGenerator.Validate(usercode);	

Credits

Thanks to ZXing.Net for QR code generation! https://github.com/micjahn/ZXing.Net

Product 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. 
.NET Framework net472 is compatible.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.51.128 85 11/1/2024
8.51.127.1032 130 5/8/2024