public IEnumerable<char> Generate(int numericBase, CharsetGenerator charsetGenerator) { numericBase = charsetGenerator.NumericSystemLimiter(numericBase); List<char> result = new List<char>(numericBase); for (int i = 0; i < numericBase && i < charsetGenerator.CharsetLimit; ++i) result.Add(charsetGenerator.AvailableCharacters[i]); return result; }
public IEnumerable<char> Generate(int numericBase, CharsetGenerator charsetGenerator) { numericBase = charsetGenerator.NumericSystemLimiter(numericBase); List<char> result = new List<char>(numericBase); List<char> buffer = new List<char>(numericBase); buffer.AddRange(charsetGenerator.AvailableCharacters); CryptoRandom rnd = new CryptoRandom(); while (buffer.Count > 0) { byte index = rnd.Next((byte)(buffer.Count)); result.Add(buffer[index]); buffer.RemoveAt(index); } return result; }