private void EnsureRequiredSets(IList <int> remainingPositions, char[] password) { // If strong passwords are required, generate a character for the required number // of sets and place them at random points within the generated password. This // will ensure that the resulting password will pass validation. var availableSets = new List <PasswordCharacterSet>(_options.CharacterSets); for (var i = 0; i < _options.RequiredSets; i++) { var characterSet = _rangePicker.GetRandomFrom(availableSets); var position = _rangePicker.GetRandomFrom(remainingPositions); var randomChar = characterSet.GetRandomCharacter(_rangePicker); password.SetValue(randomChar, position); availableSets.Remove(characterSet); remainingPositions.Remove(position); } }
public char GetRandomCharacter(RangePicker rangePicker) { return(rangePicker.GetRandomFrom(_characters)); }