public void GetHashedString_WhenParametersAreTheSame_AlwaysCreatesIdenticalValue(string pass, string salt)
        {
            var result = EncryptionHelpers.GetHashedString(pass, salt);

            var result2 = EncryptionHelpers.GetHashedString(pass, salt);

            Assert.Equal(result, result2);
        }
        public void GetHashedString_ChangesStringValue()
        {
            var original = "test value";

            var result = EncryptionHelpers.GetHashedString(original, "any salt");

            Assert.NotEqual(original, result);
        }
        public void GetHashedString_CreatesDifferentValuesForDifferentSalts()
        {
            var value = "test value";

            var result  = EncryptionHelpers.GetHashedString(value, "salt");
            var result2 = EncryptionHelpers.GetHashedString(value, "different salt");

            Assert.NotEqual(result, result2);
        }
        public void GetHashedString_CreatesDifferentValuesForDifferentStrings()
        {
            var salt = "test salt";

            var result  = EncryptionHelpers.GetHashedString("test 1", salt);
            var result2 = EncryptionHelpers.GetHashedString("different test", salt);

            Assert.NotEqual(result, result2);
        }
示例#5
0
        public void Create_WithUsernameAndPassword_EncryptsPassword()
        {
            var givenEmail    = "email";
            var givenPassword = "******";
            var result        = _subject.Create(givenEmail, givenPassword);

            var encryptedPassword = EncryptionHelpers.GetHashedString(givenPassword, result.Salt);

            Assert.Equal(encryptedPassword, result.Password);
        }
示例#6
0
        public User Create(string email, string password)
        {
            Guard.NotNull(email, "Email Address");
            Guard.NotNull(password, "Password");

            var salt = EncryptionHelpers.CreateSalt(10);
            var encryptedPassword = EncryptionHelpers.GetHashedString(password, salt);

            return(new User()
            {
                EmailAddress = email,
                Password = encryptedPassword,
                Salt = salt
            });
        }