private IAuthenticationService GetSut() { var hmacGenerator = new Sha1HmacGenerator(); var otpGenerator = new OtpGenerator(hmacGenerator); var sut = new AuthenticationService(otpGenerator); return sut; }
public void GenerateOtp_WhenCalled_ReturnsTheCorrectOtp(int counter, string expectedResult) { // arrange var sha1HmacGenerator = new Sha1HmacGenerator(); var sut = new OtpGenerator(sha1HmacGenerator); var secretKey = Encoding.ASCII.GetBytes("12345678901234567890"); // act var actual = sut.GenerateOtp(counter, secretKey, 6); // assert Assert.AreEqual(expectedResult, actual); }
private static void Main(string[] args) { var userId = "123456"; var currentDate = DateTime.Now; var hmacGenerator = new Sha1HmacGenerator(); var otpGenerator = new OtpGenerator(hmacGenerator); var authenticationService = new AuthenticationService(otpGenerator); var password = authenticationService.GneratePassword(Encoding.ASCII.GetBytes(userId), currentDate); Console.WriteLine("Yor password is: {0}", password); Console.ReadKey(); }