Example #1
0
        public void ThenItShouldGenerateCorrectCode(string sharedSecret, long counter, string expectedCode)
        {
            // Arrange
            var generator = new HmacSha1HotpGenerator(new HotpGeneratorSettings
            {
                SharedSecret = OtpSharedSecret.FromAsciiString(sharedSecret)
            });

            // Act
            var actual = generator.Generate(counter);

            // Assert
            Assert.AreEqual(expectedCode, actual);
        }
Example #2
0
        public void ThenItShouldGenerateCorrectCode(string sharedSecret, long secondsSinceEpoch, string expectedCode)
        {
            // Arrange
            var generator = new HmacSha512TotpGenerator(new TotpGeneratorSettings
            {
                SharedSecret = OtpSharedSecret.FromAsciiString(sharedSecret)
            });
            var time = new DateTime(1970, 1, 1).AddSeconds(secondsSinceEpoch);

            // Act
            var actual = generator.Generate(time);

            // Assert
            Assert.AreEqual(expectedCode, actual);
        }