static void WriteTestHash(IPasswordHash ph, string password) { Console.WriteLine("Class: {0}", ph.GetType()); string hash = ph.Hash(password); Console.WriteLine("Password: {0}", password); Console.WriteLine("Hash: {0}", hash); Console.WriteLine("Match: {0}", ph.Verify(password, hash)); Console.WriteLine(); }
public void Create(string name, string password) { Validate.NotNullOrBlank(name, "Name cannot be blank."); Validate.NotNullOrBlank(password, "Password cannot be blank."); Validate.ShouldThrow <UserNotExistsException>(() => { Find(name); }, "User " + name + " already exists."); ValidatePassword(password); var hashedPassword = _passwordHash.Hash(password); var user = new User { Name = name, PasswordHash = hashedPassword }; _databaseContext.Add(user); _databaseContext.SaveChanges(); }