A .NET core library that implements HOTP based on rfc4226 and TOTP based on rfc6238.
It's compatible with the Google Authenticator App.
First, we need to create a shared secret (stored on the server and by the client)
var secret = OneTimePassword.CreateSharedSecret();
For a time-based token, we use:
OneTimePassword.TimeBasedPassword(secret)
For a counter-based token, we use:
OneTimePassword.CounterBasedPassword(secret, 1)
The counter here is 1.
To get a Google Authenticator friendly shared secret:
OneTimePassword.SharedSecretToString(secret);
One Time Password targets the .NET Standard 1.6, which should be compatible with .NET Framework 4.6.1 and .NET Core 1.0. For other frameworks, please see this.
It's seems to be important to install NETStandard.Library for everything to work, especially on the .NET Framework.