Exemple #1
0
 public void Test()
 {
     lock (TotpHelper.ConfigureTotpOptions(null))
     {
         var bizToken = "test_xxx";
         var code     = TotpHelper.GenerateCode(bizToken);
         Thread.Sleep(2000);
         Assert.True(TotpHelper.VerifyCode(bizToken, code));
     }
 }
Exemple #2
0
 public void Test()
 {
     lock (_lock)
     {
         TotpHelper.ConfigureTotpOptions(options =>
         {
             options.Salt      = null;
             options.ExpiresIn = 300;
         });
         var bizToken = "test_xxx";
         var code     = TotpHelper.GenerateCode(bizToken);
         Thread.Sleep(2000);
         Assert.NotEmpty(code);
         Assert.True(TotpHelper.VerifyCode(bizToken, code));
     }
 }
Exemple #3
0
        public void SaltTest()
        {
            var bizToken = "test_xxx";
            var code     = TotpHelper.GenerateCode(bizToken);

            lock (TotpHelper.ConfigureTotpOptions(options =>
            {
                options.Salt = "amazing-dotnet";
            }))
            {
                var code1 = TotpHelper.GenerateCode(bizToken);
                Thread.Sleep(2000);
                Assert.False(TotpHelper.VerifyCode(bizToken, code));
                Assert.True(TotpHelper.VerifyCode(bizToken, code1));
            }
        }
    public void SaltTest()
    {
        lock (_lock)
        {
            TotpHelper.ConfigureTotpOptions(options => options.Salt = null);
            var code = TotpHelper.GenerateCode(bizToken);
            Assert.NotEmpty(code);

            TotpHelper.ConfigureTotpOptions(options =>
            {
                options.Salt      = "amazing-dotnet";
                options.ExpiresIn = 300;
            });
            Assert.False(TotpHelper.VerifyCode(bizToken, code));

            var code1 = TotpHelper.GenerateCode(bizToken);
            Assert.NotEmpty(code1);
            Thread.Sleep(2000);
            Assert.True(TotpHelper.VerifyCode(bizToken, code1));
        }
    }