One-Time password library, providing .NET implementations of HOTP (RFC4226) and TOTP (RFC6238)
The Implementations of both algorithms is based on the reference implementations listed in the relevant RFC.
You can install the package from nuget.org
Install-Package simonbu11.otp
Create a generator
var generator = new HmacSha1HotpGenerator(new HotpGeneratorSettings
{
SharedSecret = OtpSharedSecret.FromAsciiString(sharedSecret)
});
generate code from counter
var counter = 1;
var code = generator.Generate(counter);
Create a generator
// There are 3 TOTP generator implementations - HmacSha512TotpGenerator, HmacSha256TotpGenerator & HmacSha1TotpGenerator
var generator = new HmacSha512TotpGenerator(new HotpGeneratorSettings
{
SharedSecret = OtpSharedSecret.FromAsciiString(sharedSecret)
});
Then either generate a code from a specific time
var time = DateTime.Now;
var actual = generator.Generate(time)
Or either generate a code from a specific time-step
var timeStep = 1234567890;
var actual = generator.Generate(timeStep)
## License This project is licensed under the MIT license, you can find a copy of the license in the LICENSE file.