TwoFactor.net 1.0.1

Generate 2FA codes.

Install-Package TwoFactor.net -Version 1.0.1
dotnet add package TwoFactor.net --version 1.0.1
<PackageReference Include="TwoFactor.net" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TwoFactor.net --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
using System;
using TwoFactorAuthentication;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            //Generate 2FA code(Client)
            var generator = new TwoFactor("SECRET");
            Console.WriteLine(generator.GenerateCode());
            
            //Get input from console.
            string code;
            do
                Console.Write("Enter a generated 2FA code to check: ");
            while ((code = Console.ReadLine()).Length != 6);

            //Check 2FA code(Server)
            Console.WriteLine(generator.ValidateCode(code)?"Code is valid.":"Code is invalid.");
            Console.ReadLine();
            
            //Generate new 2FA secret (static)
            string secret = TwoFactor.GenerateSecret();
        }
    }        
}
using System;
using TwoFactorAuthentication;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            //Generate 2FA code(Client)
            var generator = new TwoFactor("SECRET");
            Console.WriteLine(generator.GenerateCode());
            
            //Get input from console.
            string code;
            do
                Console.Write("Enter a generated 2FA code to check: ");
            while ((code = Console.ReadLine()).Length != 6);

            //Check 2FA code(Server)
            Console.WriteLine(generator.ValidateCode(code)?"Code is valid.":"Code is invalid.");
            Console.ReadLine();
            
            //Generate new 2FA secret (static)
            string secret = TwoFactor.GenerateSecret();
        }
    }        
}

  • .NETCoreApp 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 102 6/27/2019