public void TestingSha1() { string secret = "SomeKey"; byte[] key = Encoding.UTF8.GetBytes(secret); long interval = 66778; int returnDigits = 6; var hmacSha = new HashSha1(); OneTimePassword generator = new OneTimePassword(key, hmacSha, returnDigits); String otp = generator.Generate("12345", interval); Assert.IsNotNull(otp); Assert.AreEqual(6, otp.Length); Assert.AreEqual("337162", otp); }
public void TestingUserIdWithoutInterval() { string secret = "SomeKey"; byte[] key = Encoding.UTF8.GetBytes(secret); var hmacSha1 = new HashSha1(); OneTimePassword generator = new OneTimePassword(key, hmacSha1); String otp = generator.Generate("user", 0); Assert.AreEqual(OneTimePassword.MAXIMUM_DIGITS, otp.Length); Assert.AreEqual("31249860", otp); }