Beispiel #1
0
        public async Task NotSameTotp_OutOfTimeStep_Encrypted()
        {
            while (true)
            {
                if (DateTime.Now.Second % 5 == 0)
                {
                    break;
                }
                await Task.Delay(800);
            }

            var totp = new Totp()
                       .Secret(Key)
                       .Length(8)
                       .ValidFor(TimeSpan.FromSeconds(5))
                       .UseDefaultEncryptor(_aesKey, _aesIv);

            var value1    = totp.ComputeEncrypted();
            var value1Dec = totp.Decrypt(value1);

            await Task.Delay(6000);

            var value2    = totp.ComputeEncrypted();
            var value2Dec = totp.Decrypt(value2);

            Assert.AreNotEqual(value1Dec, value2Dec);
        }