public void Next(byte[] buffer, int offset, int count) { if (_writing) { _entropySource.NextBytes(buffer, offset, count); } else { throw new InvalidOperationException(); } }
/// <inheritdoc /> public override void NextBytes( byte[] buffer, int offset, int count) { lock (this) { _csRng.NextBytes(buffer, offset, count); var maxWindow = Math.Min(count, _maxWindowSize); var windowOffset = _csRng.Next(maxWindow + 1); var windowSize = _csRng.Next(count - windowOffset); Array.Reverse(buffer, offset + windowOffset, windowSize); } }
public override void NextBytes( byte[] buffer, int offset, int count) { lock (this) { int done = 0; while (done < count) { if (_windowCount < 1) { _csRng.NextBytes(_window, 0, _window.Length); _windowCount = _window.Length; } buffer[offset + done++] = _window[--_windowCount]; } } }