Commits

Devin Martin committed 717fd66

Add an example with the Authenticator app. Also add seconds remaining to the sample.

  • Participants
  • Parent commits e6a0a66

Comments (0)

Files changed (2)

File OtpSharp/linqpad-samples/Basic Example.linq

   <Namespace>OtpSharp</Namespace>
 </Query>
 
-var totp = (Totp)KeyUrl.FromUrl("otpauth://totp/test?secret=AEBAGBAFAYDQQCIAAEBAGBAFAYDQQCIAAEBAGBAFAYDQQCIA");
+var url = "otpauth://totp/linqpad@test.com?secret=AEBAGBAFAYDQQCIAAEBAGBAFAYDQQCIAAEBAGBAFAYDQQCIA";
+var totp = (Totp)KeyUrl.FromUrl(url);
+
 totp.ComputeTotp().Dump("Timed One Time Password");
+totp.RemainingSeconds().Dump("Remaining seconds");

File OtpSharp/linqpad-samples/Google Authenticator Demo.linq

+<Query Kind="Statements">
+  <Reference>&lt;RuntimeDirectory&gt;\System.Web.dll</Reference>
+  <NuGetReference>OtpSharp</NuGetReference>
+  <Namespace>OtpSharp</Namespace>
+  <Namespace>System.Web</Namespace>
+</Query>
+
+/* Scan the following QR code with the Google authenticator app.
+ * Make sure the clock on your computer and your smartphone are in sync.
+ * 
+ * The code that is generated should match what is on your smartphone.
+ */
+ 
+var url = "otpauth://totp/linqpad@test.com?secret=AEBAGBAFAYDQQCIAAEBAGBAFAYDQQCIAAEBAGBAFAYDQQCIA";
+var totp = (Totp)KeyUrl.FromUrl(url);
+
+var qrCodeUrl = string.Format("http://qrcode.kaywa.com/img.php?s=4&d={0}", HttpUtility.UrlEncode(url));
+
+Util.Image(qrCodeUrl).Dump();
+
+totp.ComputeTotp().Dump("Timed One Time Password");
+totp.RemainingSeconds().Dump("Remaining seconds");