diff options
author | Stephen Jennings <stephen.g.jennings@gmail.com> | 2014-03-19 01:58:13 -0700 |
---|---|---|
committer | Stephen Jennings <stephen.g.jennings@gmail.com> | 2014-03-19 01:58:13 -0700 |
commit | bcae90ac8719d742233d36f9493110aed2bb194a (patch) | |
tree | 801047369a3603501b084636f37b890fe65b32f8 | |
parent | 78638ebfa58b6078a99961178da6106655a6b014 (diff) | |
download | OATH.Net-bcae90ac8719d742233d36f9493110aed2bb194a.zip OATH.Net-bcae90ac8719d742233d36f9493110aed2bb194a.tar.gz OATH.Net-bcae90ac8719d742233d36f9493110aed2bb194a.tar.bz2 |
Update README
-rw-r--r-- | README.md | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -20,17 +20,18 @@ Add to your project with "`Install-Package OATH.Net`". string secretKey = user.SecretKey; int otpDigits = 8; - Key key = new Key(secretKey); + Key key = new Key(); // Generate a new key + user.SecretKey = key.Base32; // Persist this for later + TimeBasedOtpGenerator otp = new TimeBasedOtpGenerator(key, otpDigits); return otp.GenerateOtp(DateTime.UtcNow); } public bool AuthorizedWithTOTP(string userSuppliedCode, User user) { - string secretKey = user.SecretKey; int otpDigits = 8; + Key key = new Key(user.SecretKey); - Key key = new Key(secretKey); TimeBasedOtpGenerator otp = new TimeBasedOtpGenerator(key, otpDigits); return otp.ValidateOtp(userSuppliedCode, DateTime.UtcNow); } @@ -40,11 +41,10 @@ Add to your project with "`Install-Package OATH.Net`". public bool AuthorizedWithHOTP(string userSuppliedCode, User user) { - string secretKey = user.SecretKey; int otpDigits = 8; int counterValue = user.NextCounterValue(); + Key key = new Key(user.SecretKey); - Key key = new Key(secretKey); CounterBasedOtpGenerator otp = new CounterBasedOtpGenerator(key, otpDigits); string validCode = otp.ComputeOtp(counterValue); |