コード例 #1
0
        public void CheckPasswordCorrect()
        {
            //Arrange
            var userService  = new UserSevice();
            var testPassword = "******";

            // Act
            (string password, string salt) = userService.GeneratePasswordHash(testPassword);

            // Asset
            Assert.IsTrue(userService.CheckPassword(testPassword, salt, password));
        }
コード例 #2
0
        public void CheckPasswordWrongSalt()
        {
            //Arrange
            var userService  = new UserSevice();
            var testPassword = "******";
            var wrongSalt    = CryptographyService.CreateHexStringFromByteArray(CryptographyService.GenerateSalt());

            // Act
            (string password, string salt) = userService.GeneratePasswordHash(testPassword);

            // Asset
            Assert.IsFalse(userService.CheckPassword(testPassword, wrongSalt, password));
        }